nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 4477078170628be9cd5e36a57c3cd4e6e3709e6c
parent 84e7a77a7eb0be904bedb594ae3a42820c65137e
Author: Phil Runninger <prunninger@virtualhold.com>
Date:   Mon, 17 Oct 2016 10:05:50 -0400

Unlet! the nt variable before letting it.

Some will have a "NERDTree" buffer variable and others will not. In the
ones that do, getbufvar will return a dictionary. getbufvar will return
an empty string from the other buffers. When looping through the buffers,
let will throw an error if nt already exists and is a different type than
what is trying to be put into it. This easily can be illustrated by these
two statements:

:let x = ""
:let x = {}
E706: Variable type mismatch for: x

This commit gets rid of the variable before setting it so that the
mismatch cannot occur.

Diffstat:
Mautoload/nerdtree.vim | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim
@@ -24,10 +24,13 @@ function! nerdtree#checkForBrowse(dir)
     call g:NERDTreeCreator.CreateWindowTree(a:dir)
 endfunction
 
+"FUNCTION: s:reuseWin(dir) {{{2
+"finds a NERDTree buffer with root of dir, and opens it.
 function! s:reuseWin(dir) abort
     let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
 
     for i in range(1, bufnr("$"))
+        unlet! nt
         let nt = getbufvar(i, "NERDTree")
         if empty(nt)
             continue