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,12 +2583,9 @@ 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
let treenode = s:GetSelectedNode()
if treenode != {}
if treenode.path.isDirectory if treenode.path.isDirectory
call treenode.ToggleOpen() call treenode.ToggleOpen()
call s:RenderView() call s:RenderView()
@ -2588,6 +2596,12 @@ function! s:ActivateNode()
call s:CloseTree() call s:CloseTree()
endif endif
endif endif
else
let bookmark = s:GetSelectedBookmark()
if bookmark != ""
call s:BookmarkToRoot(bookmark)
endif
endif
endfunction endfunction
"FUNCTION: s:BindMappings() {{{2 "FUNCTION: s:BindMappings() {{{2