mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Suppress events for intermediate window/tab/buffer changes (#1026)
* Add an optional parameter to neredtree#exec to suppress all events. The value doesn't matter, but 1 is a good choice. Its presence is an indicator that tells NERDTree to tell Vim to ignore all events. I'm not yet sure if there needs to be an else section to that if block. It may be OK to allow all events to fire in the right situations. * Supress events in all intermediate nerdtree#exec calls. Finding all the right function calls is the key here. * Make ignoreAll a required parameter to nerdtree#exec(). * Put required ignoreAll argument (==0) in where it's now needed. * Ignore events when creating a new vertical split. * Ignore events when closing NERDTree. This may need to be reverted. * Remove debugging statment and commented-out code. * Wrap remaining buffer/window-switching commands in nerdtree#exec(). * Update version number. * Add a space between arguments in nerdtree#exec() calls.
This commit is contained in:
@@ -154,13 +154,13 @@ function! nerdtree#deprecated(func, ...)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#exec(cmd) {{{2
|
||||
" Same as :exec cmd but with eventignore set for the duration
|
||||
" to disable the autocommands used by NERDTree (BufEnter,
|
||||
" BufLeave and VimEnter)
|
||||
function! nerdtree#exec(cmd)
|
||||
" FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2
|
||||
" Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration
|
||||
function! nerdtree#exec(cmd, ignoreAll)
|
||||
let old_ei = &ei
|
||||
set ei=BufEnter,BufLeave,VimEnter
|
||||
if a:ignoreAll
|
||||
set ei=all
|
||||
endif
|
||||
exec a:cmd
|
||||
let &ei = old_ei
|
||||
endfunction
|
||||
|
||||
@@ -574,11 +574,11 @@ function! s:refreshRoot()
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while...")
|
||||
|
||||
let l:curWin = winnr()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1)
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#exec(l:curWin . "wincmd w")
|
||||
call nerdtree#exec(l:curWin . "wincmd w", 1)
|
||||
call nerdtree#echo("")
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user