commit 3e946b1b4fd831f992ed06fec418a1b3f1eada65
parent 2a16431b2d9780bb329ed36d54f7758664417197
Author: Martin Grenfell <martin_grenfell@msn.com>
Date: Sat, 28 Jun 2008 20:43:33 +1200
make 'o' active bookmarks as well
hitting 'o' or clicking a bookmark will now make that bookmark to the
new tree root, in the same way that :BookmarkToRoot does
Diffstat:
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -1990,6 +1990,17 @@ function! s:GetPath(ln)
return toReturn
endfunction
+"FUNCTION: s:GetSelectedBookmark() {{{2
+"Returns the current node if it is a dir node, or else returns the current
+"nodes parent
+function! s:GetSelectedBookmark()
+ let line = getline(".")
+ let name = substitute(line, '^>\(.\{-}\) \[.*\]$', '\1', '')
+ if name != line
+ return name
+ endif
+endfunction
+
"FUNCTION: s:GetSelectedDir() {{{2
"Returns the current node if it is a dir node, or else returns the current
"nodes parent
@@ -2572,20 +2583,23 @@ function! s:ActivateNode()
if getline(".") == s:tree_up_dir_line
return s:UpDir(0)
endif
- let treenode = s:GetSelectedNode()
- if treenode == {}
- call s:EchoWarning("cannot open selected entry")
- return
- endif
- if treenode.path.isDirectory
- call treenode.ToggleOpen()
- call s:RenderView()
- call s:PutCursorOnNode(treenode, 0, 0)
+ let treenode = s:GetSelectedNode()
+ if treenode != {}
+ if treenode.path.isDirectory
+ call treenode.ToggleOpen()
+ call s:RenderView()
+ call s:PutCursorOnNode(treenode, 0, 0)
+ else
+ call s:OpenFileNode(treenode)
+ if g:NERDTreeQuitOnOpen
+ call s:CloseTree()
+ endif
+ endif
else
- call s:OpenFileNode(treenode)
- if g:NERDTreeQuitOnOpen
- call s:CloseTree()
+ let bookmark = s:GetSelectedBookmark()
+ if bookmark != ""
+ call s:BookmarkToRoot(bookmark)
endif
endif
endfunction