mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 11:17:20 +08:00
Check for error; remove code duplication
This commit is contained in:
parent
7c8c811f00
commit
7e00a9971e
|
@ -142,18 +142,9 @@ function! s:chRoot(node)
|
|||
endfunction
|
||||
|
||||
" 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()
|
||||
try
|
||||
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))
|
||||
NERDTreeCWD
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
|
||||
|
|
|
@ -202,7 +202,14 @@ function! NERDTreeFocus()
|
|||
endfunction
|
||||
|
||||
function! NERDTreeCWD()
|
||||
let l:cwdPath = g:NERDTreePath.New(getcwd())
|
||||
|
||||
try
|
||||
let l:cwdPath = g:NERDTreePath.New(getcwd())
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echoWarning('current directory does not exist')
|
||||
return
|
||||
endtry
|
||||
|
||||
call NERDTreeFocus()
|
||||
|
||||
if b:NERDTree.root.path.equals(l:cwdPath)
|
||||
|
|
Loading…
Reference in New Issue
Block a user