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.
This commit is contained in:
Phil Runninger 2016-10-17 10:05:50 -04:00
parent 84e7a77a7e
commit 4477078170

View File

@ -24,10 +24,13 @@ function! nerdtree#checkForBrowse(dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir) call g:NERDTreeCreator.CreateWindowTree(a:dir)
endfunction endfunction
"FUNCTION: s:reuseWin(dir) {{{2
"finds a NERDTree buffer with root of dir, and opens it.
function! s:reuseWin(dir) abort function! s:reuseWin(dir) abort
let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
for i in range(1, bufnr("$")) for i in range(1, bufnr("$"))
unlet! nt
let nt = getbufvar(i, "NERDTree") let nt = getbufvar(i, "NERDTree")
if empty(nt) if empty(nt)
continue continue