mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
fix a bug when opening files in a new tab
On bufleave we save the nerdtree window state. However, sometimes when bufleave is triggered the tree is no longer open in this tab - e.g. for secondary trees or mappings that open in another tab. Dont bother saving screen state in these cases as the code doing the saving assumes the tree is available in this tab.
This commit is contained in:
@@ -325,13 +325,6 @@ endfunction
|
|||||||
"Saves the current cursor position in the current buffer and the window
|
"Saves the current cursor position in the current buffer and the window
|
||||||
"scroll position
|
"scroll position
|
||||||
function! s:UI.saveScreenState()
|
function! s:UI.saveScreenState()
|
||||||
|
|
||||||
"FIXME: b:NERDTreeType should really me moved to b:NERDTree.type. Update
|
|
||||||
"this when that refactor is done
|
|
||||||
if b:NERDTreeType == "secondary"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let win = winnr()
|
let win = winnr()
|
||||||
call g:NERDTree.CursorToTreeWin()
|
call g:NERDTree.CursorToTreeWin()
|
||||||
let self._screenState = {}
|
let self._screenState = {}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ call nerdtree#ui_glue#setupCommands()
|
|||||||
"============================================================
|
"============================================================
|
||||||
augroup NERDTree
|
augroup NERDTree
|
||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()"
|
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
|
||||||
|
|
||||||
"disallow insert mode in the NERDTree
|
"disallow insert mode in the NERDTree
|
||||||
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
||||||
|
|||||||
Reference in New Issue
Block a user