nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit da3874cf933e3736f9a8d1a2cfe35943d88fa94b
parent 7270212214660961df9a06846cdd4a36cf1b6fc0
Author: Martin Grenfell <martin.grenfell@gmail.com>
Date:   Mon,  4 May 2015 20:25:03 +0100

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.

Diffstat:
Mlib/nerdtree/ui.vim | 7-------
Mplugin/NERD_tree.vim | 2+-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git 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
@@ -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"