From da3874cf933e3736f9a8d1a2cfe35943d88fa94b Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 4 May 2015 20:25:03 +0100 Subject: [PATCH] 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. --- lib/nerdtree/ui.vim | 7 ------- plugin/NERD_tree.vim | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 41ec21d..22e450c 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -325,13 +325,6 @@ endfunction "Saves the current cursor position in the current buffer and the window "scroll position 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() call g:NERDTree.CursorToTreeWin() let self._screenState = {} diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3eae93b..bd911c6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,7 +148,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "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 exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"