From bc572aff4f5dbb59354733987c3936391a364f3a Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 12 Jun 2019 08:37:42 -0400 Subject: [PATCH 1/2] Fix "R doesn't work when doing 'vim '" a different way. Instead of assigning a value to t:NERDTreeBufName for a window tree, which is used to determine if NERDTree is open, simply also look at the current buffer's name to see if it matches the NERDTree pattern. --- lib/nerdtree/creator.vim | 3 +-- lib/nerdtree/nerdtree.vim | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index a893c17e..5eac168d 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -96,8 +96,7 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - let t:NERDTreeBufName = self._nextBufferName() - exec g:NERDTreeCreatePrefix . " edit " . t:NERDTreeBufName + exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") let b:NERDTree._previousBuf = bufnr(previousBuf) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index c1ce5ed0..a599b3cc 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -153,7 +153,7 @@ endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 + return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^NERD_tree_\d\+$' endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 From 1e290dcccc2ebb7b4f7bfc395c2b5ac1a1d6426c Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 12 Jun 2019 09:01:42 -0400 Subject: [PATCH 2/2] Replace hardcoded buffer name prefix with BufNamePrefix() function. --- lib/nerdtree/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a599b3cc..e5ba0b5d 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -153,7 +153,7 @@ endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^NERD_tree_\d\+$' + return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1