From 2e6cedcad758e18cf6568bfe9aeacafe9ee79984 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 9 Jan 2009 18:11:36 +1300 Subject: [PATCH] fix the q mapping again since we are now ":edit"ing a new buffer for secondary nerd trees, we have to store the previous buffer number otherwise we get into an infinite loop because we go back to a directory buffer which causes another secondary nerd tree to open etc --- plugin/NERD_tree.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index cdd8a37..b769f8b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2074,10 +2074,17 @@ function! s:initNerdTreeInPlace(dir) return endtry + + let previousBuf = expand("#") + "we need a unique name for each secondary tree buffer to ensure they are "all independent exec "silent edit " . s:nextBufferName() + if previousBuf !~ s:NERDTreeBufName . '.*' + let b:NERDTreePreviousBuf = previousBuf + endif + let b:NERDTreeRoot = s:TreeDirNode.New(path) call b:NERDTreeRoot.open() @@ -3178,10 +3185,14 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{2 " close the tree window function! s:closeTreeWindow() - if b:NERDTreeType == "secondary" - buffer # + if b:NERDTreeType == "secondary" && exists("b:NERDTreePreviousBuf") + exec "buffer " . b:NERDTreePreviousBuf else - wincmd c + if winnr("$") > 1 + wincmd c + else + call s:echo("Cannot close last window") + endif endif endfunction " FUNCTION: s:copyNode() {{{2