bugfix: the script failed when being initialized on a dir containing spaces

This commit is contained in:
Martin Grenfell
2008-04-17 23:39:23 +12:00
parent c008fb3983
commit 7d1cc4ecec
2 changed files with 7 additions and 3 deletions

View File

@@ -999,3 +999,6 @@ the &hidden option is set.
Thanks to Olivier Yiptong for prompting me to make line numbers in the Thanks to Olivier Yiptong for prompting me to make line numbers in the
NERD tree window optional. NERD tree window optional.
Thanks to Zhang Shuhan for a bug report when initializing the tree in a dir
containing spaces.

View File

@@ -1312,7 +1312,9 @@ function! s:InitNerdTree(dir)
let dir = a:dir == '' ? expand('%:p:h') : a:dir let dir = a:dir == '' ? expand('%:p:h') : a:dir
let dir = resolve(dir) let dir = resolve(dir)
if !isdirectory(dir) let path = s:oPath.New(dir)
if !path.isDirectory
call s:EchoWarning("Error reading: " . dir) call s:EchoWarning("Error reading: " . dir)
return return
endif endif
@@ -1320,7 +1322,7 @@ function! s:InitNerdTree(dir)
"if instructed to, then change the vim CWD to the dir the NERDTree is "if instructed to, then change the vim CWD to the dir the NERDTree is
"inited in "inited in
if g:NERDTreeChDirMode != 0 if g:NERDTreeChDirMode != 0
exec "cd " . dir exec "cd " . path.StrForOS(1)
endif endif
let t:treeShowHelp = 0 let t:treeShowHelp = 0
@@ -1333,7 +1335,6 @@ function! s:InitNerdTree(dir)
unlet t:NERDTreeRoot unlet t:NERDTreeRoot
endif endif
let path = s:oPath.New(dir)
let t:NERDTreeRoot = s:oTreeDirNode.New(path) let t:NERDTreeRoot = s:oTreeDirNode.New(path)
call t:NERDTreeRoot.Open() call t:NERDTreeRoot.Open()