diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index ce7cca9..d2788b2 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -999,3 +999,6 @@ the &hidden option is set. Thanks to Olivier Yiptong for prompting me to make line numbers in the NERD tree window optional. + +Thanks to Zhang Shuhan for a bug report when initializing the tree in a dir +containing spaces. diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index aa8228a..9489907 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1312,7 +1312,9 @@ function! s:InitNerdTree(dir) let dir = a:dir == '' ? expand('%:p:h') : a:dir let dir = resolve(dir) - if !isdirectory(dir) + let path = s:oPath.New(dir) + + if !path.isDirectory call s:EchoWarning("Error reading: " . dir) return endif @@ -1320,7 +1322,7 @@ function! s:InitNerdTree(dir) "if instructed to, then change the vim CWD to the dir the NERDTree is "inited in if g:NERDTreeChDirMode != 0 - exec "cd " . dir + exec "cd " . path.StrForOS(1) endif let t:treeShowHelp = 0 @@ -1333,7 +1335,6 @@ function! s:InitNerdTree(dir) unlet t:NERDTreeRoot endif - let path = s:oPath.New(dir) let t:NERDTreeRoot = s:oTreeDirNode.New(path) call t:NERDTreeRoot.Open()