From 4477078170628be9cd5e36a57c3cd4e6e3709e6c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 17 Oct 2016 10:05:50 -0400 Subject: [PATCH] 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. --- autoload/nerdtree.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index bbf6087..b0eb103 100644 --- 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