-
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
Suppress autocmds less aggressively #578
Conversation
This is the counterpart to a PR I just submitted to undotree (mbbill/undotree#61). I noticed that my statusline doesn't update properly when using NERDTree to move between revisions of a file with `go` or `gi` (wincent/wincent#16). I established that this was because it was using `'eventignore'` to suppress all autocmds, which in turn prevents the statusline from updating. Commenting out the `set eventignore=all` line makes the failure to update go away, at the cost of firing more autocmds. I considered adding an option for opting out of this behavior (eg. `let g:NERDTreeEventignore=0` or something), or rearchitecting my statusline to use an approach like vim-airline does based on CursorMoved autocmds (see vim-airline/vim-airline#82; see also https://github.com/vim-airline/vim-airline/blob/30f078daf569e7d5e4f7829e39316387af349b41/plugin/airline.vim#L36-L50 for current implementation), but then realized that a simpler fix is to have NERDTree just disable only the autocmds that it uses instead of disabling all of them. This is probably not enough to unbreak every bit of code in the world that depends on those autocmds, but it does at least unbreak my use case, because it allows my `WinLeave` autocmd to run and update the statusline.
Upstream PR is: preservim/nerdtree#578 Closes: #16
Friendly ping. Got any feedback on this PR? Thanks. |
This change dramatically effects the speed of opening files via NERDtree for me (for the worse). Files take a second or more to load, where previously they used to load instantly. This line in autoload/nerdtree.vim is the culprit:
I set my own statusline and I listen on VimEnter,WinEnter,BufWinEnter,InsertLeave events to change the statusline depending on normal/insert/visual or replace modes. My slowness issue is fixed if I change the above line in autoload/nerdtree.vim to:
Notice the extra WinEnter. Previously in NERDtree it was:
Any chance of adding the WinEnter option to the current ei setting? |
@bluz71: The reason things slow down when the Note that NERDTree itself does not make use of the |
I have my own function hooked up to WinEnter, one of the things that it did (apart from setting my statusline) was it auto-refreshed my NERDtree pane if I focussed back into the NERDtree pane. Basically I called this function (via an autocmd for WinEnter):
That now is a very slow operation with this particular Git commit. Do you know of any other way to auto-refresh the NERDtree, inexpensively, when focussing back into NERDtree? I tried created a new autocmd, but this one is not firing at all:
??? |
This crude autocmd exhibits the slowness I am now experiencing (easy for you to test):
Without this Git commit it is quite fast. Basically I want a way to auto refresh NERDtree, I don't care how to achieve it. Any ideas? |
I think I've fixed my issue in my vimrc. This rule appears to be working AND with no NERDTree slowdown:
Basically I moved my NERDTreeRefresh out of WinEnter and into BufEnter. Functionality seems the same but with no speed issues. |
Awesome. Glad that you sorted it out. |
Greetings, I haven't read this entire thread, but I will when I have the time. Since this pull request has just come to my attention, I wanted to leave my thoughts before further commits to this repository are made.
I certainly agree with the change, and I'm glad to see it merged. I, too, thought the previous solution was overly aggressive. The commit should be amended to change the function comment and to use the commit message to close issue #640. I hope @wincent and @PhilRunninger can work this out. Thanks, guys! |
This is the counterpart to a PR I just submitted to undotree (mbbill/undotree#61).
I noticed that my statusline doesn't update properly when using NERDTree to move between revisions of a file with
go
orgi
(wincent/wincent#16). I established that this was because it was using'eventignore'
to suppress all autocmds, which in turn prevents the statusline from updating.Commenting out the
set eventignore=all
line makes the failure to update go away, at the cost of firing more autocmds.I considered adding an option for opting out of this behavior (eg.
let g:NERDTreeEventignore=0
or something), or rearchitecting my statusline to use an approach like vim-airline does based on CursorMoved autocmds (see vim-airline/vim-airline#82; see also https://github.com/vim-airline/vim-airline/blob/30f078daf569e7d5e4f7829e39316387af349b41/plugin/airline.vim#L36-L50 for current implementation), but then realized that a simpler fix is to have NERDTree just disable only the autocmds that it uses instead of disabling all of them.This is probably not enough to unbreak every bit of code in the world that depends on those autocmds, but it does at least unbreak my use case, because it allows my
WinLeave
autocmd to run and update the statusline.