-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NERDTree: Refreshing the root node. This could take a while... #684
Comments
Any idea please? |
@gpakosz, your WinEnter autocmd is causing this behavior because of the PR you identified. If you remove that line, you will see the responsiveness improve, but of course NERDTree won't @wincent, what do you think about adding WinEnter into the list of ignored events? Would that cause any interference that your PR intended to eliminate? @scrooloose , any thoughts? |
@PhilRunninger. I don't think adding Rather than add |
I agree you, @wincent. Thanks for giving your opinion. |
Thanks for the insight. The issue I'm facing is partly due to my Vim ignorance. Is there a way to replace
to something that would trigger a refresh when moving from any window to the NERDTree window? As far as I understand, what I'm facing is NERDTree refreshing itself when moving away from the NERDTree window. |
You can try to figure out what autocommands are firing with something like:
Then do stuff, then look in the You shouldn't get a There might be an alternate implementation you can do that relies on the following:
Or something like that. |
In a simple investigation, I used
to track which windows are being entered. It turns out NERDTree is switching windows a couple of times when you select a file to open, as seen below. I had
I don't know what's going on in the code, or why, but with your autocmd, it is triggering a Refresh of the root node three times each time you open a file to edit. |
I take the blame for putting an Yet that ping-pong even before opening the new file is dubious 🤔 |
I can confirm that when disabling all my
I'm observing the same behavior as you:
NERDTree switches windows 3 times. I'm still unsure how to debug this being really unfamiliar with vimscript |
NERDTree relies on executing 'wincmd p' back and forth as part of its normal operation. This implementation detail is not obvious to NERDTree users that may set up autocommands. As such, it makes sense to ignore WinEnter and WinLeave autocmnds in nerdtree#exec(cmd). This PR fixes preservim#684.
Alright, a few When activating a file node, we end up in
This explains the first two ping-pongs. I can mitigate them by rewriting
The last ping pong is caused by
So yeah, NERDTree depends a lot on being able to ping-pong with |
The problem with ignoring those autocommands, @gpakosz, is that it would break the set-up of anybody who relies on them, with no way of avoiding the breakage short of forking NERDTree or never upgrading it. On the other hand, not ignoring them leads to two possible outcomes, both of which are better than outright breakage: either the user does nothing and sees a slowdown (but only if their autocommands are expensive), or they implement a workaround using some global variables like I suggested above. The point is, they have options. Another question is whether NERDTree should be doing this pingpong thing in the first place. It does sound a bit kludgish, so perhaps the answer is "ideally not". One final observation: if we can't reach an agreement on which autocommands should be ignored, that itself may be evidence of the fact that it should be configurable (an unpleasantly low level configuration, for sure) or perhaps you are solving the wrong problem in the first place: if you want to run something on entering NERDTree, and if NERDTree is going to break Vim's built-in mechanism for responding to such an event (ie. |
I can't seem to find it now, but I remember seeing another issue very similar to this, where the OP solved the unresponsiveness by using |
@wincent I will try to debug more and educate myself more because at that point I still fail to understand how as a user one would rely on NERDTree pingponging between windows as an implementation detail 😐 It seems to me that all but the last |
@gpakosz Have you tried using |
Toggling |
BufEnter will fire when you switch from another window into a NERDTree window that's already open. I thought that was the situation you were trying to handle with WinEnter. To refresh NERDTree when toggling it, why not change your
or
|
@PhilRunninger, this is exactly what I was going to suggest... that he stack the command to refresh on top of the You might make one adjustment: function! s:NERDTreeToggleWithRefresh()
if exists('b:NERDTree')
NERDTreeClose
else
NERDTreeFocus
exe 'silent normal R'
endif
endfunction
nmap <silent> <C-N> :call <SID>NERDTreeToggleWithRefresh()<CR> This doesn't exactly toggle the NERDTree. You'd need some kind of method on the NERDTree object to determine if a tree was open or not (this is doable if it's not done already...). This is basically the same as above, but it's a little cleaner because it's a script-local function for the EDIT: Just realized the |
@PhilRunninger With
@lifecrisis I don't understand the "This doesn't exactly toggle the NERDTree" part and why it matters. As for the "You'd need some kind of method on the NERDTree object to determine if a tree was open or not" I guess you're after So far, I went for
What do you recommend between |
Note that I still believe NERDTree should filter some |
Better would be to not ping-pong in the first place, but I don't know how easy/tractable making such a change would be. |
Looks like progress on this has stalled. Closing. If anything can be done that will satisfy everyone in the future, we'll require a separate issue with a clearly defined problem and solution. |
Coming momentarily, a PR to address the ping-ponging mentioned above. |
Environment:
:version
: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 11 2017 10:04:07)git rev-parse --short HEAD
: 45f4d61Process:
$ vim path/to/file
Current Result:
NERDTree displays:
and
DONE
is somewhat blinking before it's really done.Expected Result:
Previously, NERDTree would just open the file without trying to refresh its tree.
Optional
Regression has been introduced by commit
35b04fa3dfdef5cbfbcd6ada59fce3a7bc31eeaa
:The text was updated successfully, but these errors were encountered: