Check for error; remove code duplication

This commit is contained in:
Jason Franklin
2018-09-10 08:46:42 -04:00
parent 7c8c811f00
commit 7e00a9971e
2 changed files with 10 additions and 12 deletions

View File

@@ -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)