From b3b394c3290665c837670c3e2a0f73a14b8e0ad6 Mon Sep 17 00:00:00 2001 From: Benjamin Geiger Date: Wed, 15 Jun 2011 17:26:21 -0400 Subject: [PATCH] Open NERDTreeFind tree at CWD if current file is below it. --- plugin/NERD_tree.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index cabbc1d..b0b7641 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2562,7 +2562,18 @@ function! s:findAndRevealPath() endtry if !s:treeExistsForTab() - call s:initNerdTree(p.getParent().str()) + try + let cwd = s:Path.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call s:echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call s:initNerdTree(cwd.str()) + else + call s:initNerdTree(p.getParent().str()) + endif else if !p.isUnder(s:TreeFileNode.GetRootForTab().path) call s:initNerdTree(p.getParent().str())