diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 6ba9ee6..36e71ec 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -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 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 93d299e..b29a306 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -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)