make MarkToRoot() work for nodes that arent cached

now if you go :MarkToRoot foo  and foo points to a path that isnt
cached, a new tree node will be created and made root. Note that all
cached nodes will be lost as this is the same as opening a new nerd tree
This commit is contained in:
Martin Grenfell 2008-06-08 18:24:47 +12:00
parent 371379a860
commit 82c1fece9f

View File

@ -2864,7 +2864,12 @@ endfunction
" FUNCTION: s:MarkToRoot(name) {{{2
" Make the node for the given mark the new tree root
function! s:MarkToRoot(name)
let targetNode = s:GetNodeForMark(a:name, 1)
try
let targetNode = s:GetNodeForMark(a:name, 1)
catch /NERDTree.MarkNotFound/
let marks = s:GetMarks()
let targetNode = s:oTreeFileNode.New(marks[a:name])
endtry
call targetNode.MakeRoot()
call s:RenderView()
call s:PutCursorOnNode(targetNode, 0, 0)