Check for error; remove code duplication
This commit is contained in:
parent
7c8c811f00
commit
7e00a9971e
@ -142,18 +142,9 @@ function! s:chRoot(node)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
||||||
" changes the current root to CWD
|
" Change the NERDTree root to match the current working directory.
|
||||||
function! nerdtree#ui_glue#chRootCwd()
|
function! nerdtree#ui_glue#chRootCwd()
|
||||||
try
|
NERDTreeCWD
|
||||||
let cwd = g:NERDTreePath.New(getcwd())
|
|
||||||
catch /^NERDTree.InvalidArgumentsError/
|
|
||||||
call nerdtree#echo("current directory does not exist.")
|
|
||||||
return
|
|
||||||
endtry
|
|
||||||
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree))
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
|
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
|
||||||
|
@ -202,7 +202,14 @@ function! NERDTreeFocus()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! NERDTreeCWD()
|
function! NERDTreeCWD()
|
||||||
|
|
||||||
|
try
|
||||||
let l:cwdPath = g:NERDTreePath.New(getcwd())
|
let l:cwdPath = g:NERDTreePath.New(getcwd())
|
||||||
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
|
call nerdtree#echoWarning('current directory does not exist')
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
|
||||||
call NERDTreeFocus()
|
call NERDTreeFocus()
|
||||||
|
|
||||||
if b:NERDTree.root.path.equals(l:cwdPath)
|
if b:NERDTree.root.path.equals(l:cwdPath)
|
||||||
|
Loading…
Reference in New Issue
Block a user