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
This commit is contained in:
Martin Grenfell 2008-06-28 20:43:33 +12:00
parent 2a16431b2d
commit 3e946b1b4f

View File

@ -1990,6 +1990,17 @@ function! s:GetPath(ln)
return toReturn return toReturn
endfunction 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 "FUNCTION: s:GetSelectedDir() {{{2
"Returns the current node if it is a dir node, or else returns the current "Returns the current node if it is a dir node, or else returns the current
"nodes parent "nodes parent
@ -2572,20 +2583,23 @@ function! s:ActivateNode()
if getline(".") == s:tree_up_dir_line if getline(".") == s:tree_up_dir_line
return s:UpDir(0) return s:UpDir(0)
endif endif
let treenode = s:GetSelectedNode()
if treenode == {}
call s:EchoWarning("cannot open selected entry")
return
endif
if treenode.path.isDirectory let treenode = s:GetSelectedNode()
call treenode.ToggleOpen() if treenode != {}
call s:RenderView() if treenode.path.isDirectory
call s:PutCursorOnNode(treenode, 0, 0) 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 else
call s:OpenFileNode(treenode) let bookmark = s:GetSelectedBookmark()
if g:NERDTreeQuitOnOpen if bookmark != ""
call s:CloseTree() call s:BookmarkToRoot(bookmark)
endif endif
endif endif
endfunction endfunction