Suppress autocmds less aggressively

This is the counterpart to a PR I just submitted to undotree
(https://github.com/mbbill/undotree/pull/61).

I noticed that my statusline doesn't update properly when using NERDTree to move
between revisions of a file with `go` or `gi`
(https://github.com/wincent/wincent/issues/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
https://github.com/vim-airline/vim-airline/issues/82; see also
30f078daf5/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.
This commit is contained in:
Greg Hurrell 2016-05-05 09:32:19 -07:00
parent 35c859179d
commit 35b04fa3df

View File

@ -64,7 +64,7 @@ endfunction
" same as :exec cmd but eventignore=all is set for the duration
function! nerdtree#exec(cmd)
let old_ei = &ei
set ei=all
set ei=BufEnter,BufLeave,VimEnter
exec a:cmd
let &ei = old_ei
endfunction