vim-nerdtree-tabs icon indicating copy to clipboard operation
vim-nerdtree-tabs copied to clipboard

Toggling on all tabs is slow

Open jordwalke opened this issue 14 years ago • 10 comments

Great plugin!

However, when I toggle all tabs (open or close) and I have more than a couple tabs, it's pretty slow. You can see it cycle through all of the tabs and perform some operation on each.

jordwalke avatar Oct 20 '11 19:10 jordwalke

Hi Jordan,

thanks for the report. It's probably always going to be visible (I use :tabdo and as far as I know, vim doesn't allow performing operations on tabs in background, so it's necessary to switch between all of them to perform the open/close). I hope I can make it faster though by at least temporarily disabling some event handlers.

It could also be done lazily (open/close right after user switches into a tab), but that would bring some side effects. I'll take this path if the optimizations don't improve the situation enough.

jistr avatar Oct 21 '11 08:10 jistr

Sounds awesome! I really feel that this plugin could fill one of those "missing vim" features that cause people to use editors like Textmate.

jordwalke avatar Oct 22 '11 03:10 jordwalke

I usually have about ten files open, and it takes about three seconds to toggle all of them on or off. Is this what you experience?

jordwalke avatar Oct 27 '11 18:10 jordwalke

Yes, exactly, I just don't use the on/off toggling during work, so I never found out before you reported this bug. I hope I can find some time and look at this issue during this weekend.

jistr avatar Oct 27 '11 21:10 jistr

I just improved the situation a little bit with version 1.1.1. I tested with 20 tabs and it went from 15.8s to 8.4s on my computer, so it's about 50% improvement. I cannot disable any more event handlers and it seems that the most of the time is actually taken by opening the NERDTree itself, so I cannot really do anything about that.

Lazy opening on tab switch would make it instant, but it would make things internally complicated and furthermore it would just move the delay from NERDTreeTabsToggle to the tab switch. I.e. switching a tab could take about half a second (or more on slower machines), which is unpleasant as well. So I think this soulution is not worth the trouble.

I searched the internet briefly for a possibility to disable window redrawing in vim temporarily, but it seems it is not possible.

To sum it up, it's a bit better and I don't think we can push it even further, unless there's some vim or NERDTree feature I'm not aware of.

jistr avatar Oct 28 '11 17:10 jistr

Do you know if it's possible to simply "pick up" a window from one tab and move it to another - so there would only be a single window that ever contains the NERDTree, but it is moved as needed across tabs. That might cut down the time spent inside the NERDTree plugin.

jordwalke avatar Jan 04 '13 06:01 jordwalke

Hm I don't think it's possible that particular way, but it would be possible to always create a new window and show the same buffer. But I think that what I wrote in the previous comment (about lazy opening on tab switch) applies here as well. The NERDTreeTabsToggle command would get faster, but tab switching would get slower.

jistr avatar Jan 08 '13 19:01 jistr

I'll bring this up again since it's been bothering me lately. I tried this plugin which seems to keep a panel synchronized across all tabs.

It doesn't synchronize the dimensions though. http://www.vim.org/scripts/script.php?script_id=4776

jordwalke avatar Nov 21 '13 07:11 jordwalke

This issue is still a problem --- even when I have only three tabs open.

What about storing a global variable like IsOpen, and listening to BufEnter events, or something similar. When the user switches tabs, the event fires and we can check IsOpen. If it is true, open nerd tree (unless already open), and if false, close nerd tree (unless already closed).

This lazy approach ought to be more efficient.

dylan-chong avatar May 22 '18 06:05 dylan-chong

I think doing this lazily would be best at this point. It might be slow when switching tabs, but the tabdo command is really slow on GUI vims, so I think it might end up being faster to do it when you switch tabs, and only if the dimensions / open/closedness even need updating.

jordwalke avatar Dec 03 '19 00:12 jordwalke