From eee431dbd44111c858c6d33ffd366cae1f17f8b3 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 21 Oct 2016 14:47:09 +0100 Subject: [PATCH] really fix the previous buffer issue when closing a tree win So :bprev was failing to jump back to the right buffer. I dont fully understand this yet, but I'm fairly sure this is because there is a magic buffer that we delete when creating a wintree :-/ Anyway, we are explicitly storing the prev buffer again - and updating it when reusing treewins. It's worky, but there may be a superior way... --- autoload/nerdtree.vim | 1 + lib/nerdtree/nerdtree.vim | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b0eb103..e0d86ef 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -37,6 +37,7 @@ function! s:reuseWin(dir) abort endif if nt.isWinTree() && nt.root.path.equals(path) + call nt.setPreviousBuf(bufnr("#")) exec "buffer " . i return 1 endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 73a30f7..1404cee 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -186,6 +186,10 @@ function! s:NERDTree.previousBuf() return self._previousBuf endfunction +function! s:NERDTree.setPreviousBuf(bnum) + let self._previousBuf = a:bnum +endfunction + "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often function! s:NERDTree.render()