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:
@@ -114,14 +114,14 @@ function! s:promptToDelBuffer(bufnum, msg)
|
||||
let l:listedBufferCount = 0
|
||||
endif
|
||||
if l:listedBufferCount > 1
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif"
|
||||
call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif", 1)
|
||||
else
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif"
|
||||
call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif", 1)
|
||||
endif
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
call nerdtree#exec("tabnext " . s:originalTabNumber, 1)
|
||||
call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1)
|
||||
" 3. We don't need a previous buffer anymore
|
||||
exec "bwipeout! " . a:bufnum
|
||||
call nerdtree#exec("bwipeout! " . a:bufnum, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -141,17 +141,17 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
|
||||
let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'})
|
||||
endif
|
||||
" 1. ensure that a new buffer is loaded
|
||||
exec "badd " . quotedFileName
|
||||
call nerdtree#exec("badd " . quotedFileName, 1)
|
||||
" 2. ensure that all windows which display the just deleted filename
|
||||
" display a buffer for a new filename.
|
||||
let s:originalTabNumber = tabpagenr()
|
||||
let s:originalWindowNumber = winnr()
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif"
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1)
|
||||
call nerdtree#exec("tabnext " . s:originalTabNumber, 1)
|
||||
call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1)
|
||||
" 3. We don't need a previous buffer anymore
|
||||
try
|
||||
exec "confirm bwipeout " . a:bufNum
|
||||
call nerdtree#exec("confirm bwipeout " . a:bufNum, 0)
|
||||
catch
|
||||
" This happens when answering Cancel if confirmation is needed. Do nothing.
|
||||
endtry
|
||||
|
||||
Reference in New Issue
Block a user