commit 2e6cedcad758e18cf6568bfe9aeacafe9ee79984
parent d76f9366980b4fabb80130bcc7e92340a5640968
Author: Martin Grenfell <martin_grenfell@msn.com>
Date: Fri, 9 Jan 2009 18:11:36 +1300
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
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git 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