1995eaton / chromium-vim

Vim bindings for Google Chrome.
https://chrome.google.com/webstore/detail/cvim/ihlenndgcmojhcghmfjfneahoeklbjjh
MIT License
2.26k stars 325 forks source link

:tabopen command sometimes opens URL in inactive tab sometimes not #326

Open andviro opened 9 years ago

andviro commented 9 years ago

Hello! Great plugin, helped me switch from pentadactyl to chromium and (almost) never look back. But :tabopen is very annoying, because sometimes it opens url in new inactive tab, sometimes it jumps to newly open tab. Same with :tabopen!, no difference. What am I doing wrong? Chromium 43.0.2357.81, cVim 1.2.77

257 commented 9 years ago

same here.

anoda9 commented 9 years ago

Same here. To work around the issue, I'm using the following mappings to cvimrc:

map t :tabnew& map T :tabnew!

(the original mapping of "T" isn't super useful)

andviro commented 9 years ago

thanks, friend. Looks like it's working now.

1995eaton commented 9 years ago

This update should fix it. Let me know if it works for you guys.

andviro commented 9 years ago

Sorry to say, but sometimes :tabopen opens tab into background. It works correctly 9 out of 10 , but even with :tabopen! instead of tabopen it still misfires. I've noticed this behavior on this issue comments page at least couple of times, and on Facebook page. Loaded unpacked cvim extension from current Git master.

1995eaton commented 9 years ago

Just to confirm you're using the GitHub version and have updated to at least 244d152?

andviro commented 9 years ago

Yes, I've loaded current master tip at the moment, 6c6d34e.

andviro commented 9 years ago

Uh, I'm ashamed, but it seems that there was old copy of extension floating along with github master. I removed it and now there's another problem. When loaded from git master Chromium barks at some es6-style syntax like

  document.addEventListener('mousedown', event => {
    clickFocus = true;
    lastActiveElem = event.srcElement;
  });

There are some reference errors too, like missing Hints object. Is there something I'm missing from installation procedure?

1995eaton commented 9 years ago

@andviro Whoops, looks like I forgot to replace the ES6 arrow functions I used when changing some things and debugging. Should work now

andviro commented 9 years ago

Excellent, thanks. But it still works 8-9 out of 10, must be some race condition. I'm only beginning to acquaint with your code, but I think that sometimes focus is restored to window before tab creation is finalized. I've commented out window.focus() in 'hideCommandFrame' clause and now tab switches correctly every time (at least for time being). But it's temporary measure, I think that the best way would be to run command post-execution code from callback of chrome.tabs.create.

It's not my place to offer advice, and I apologise in advance, but in my experience all this fragile stuff should be run as promises with properly chained .then() callbacks. Or, better yet, shoehorned into some proper store/action/dispatcher pattern like Flux. http://alt.js.org/ is my current favorite.

achilleas-k commented 8 years ago

Has this issue been resolved in master? I'm using the Web Store and I've tested with loading unpacked master but it's hard to know if it's fixed without testing for a day or two.

I assume it hasn't been resolved since the issue is still Open.

andviro commented 8 years ago

Tabs are still opened in background randomly, 1.2.81 and git master too. I don't mind really, too damn useful plugin to complain :)