merge InitNerdTreeFromMark into InitNerdTree

This commit is contained in:
Martin Grenfell
2008-06-09 18:20:22 +12:00
parent 64514e3ceb
commit a111af5361

View File

@@ -1420,21 +1420,28 @@ function! s:GetNodeForMark(name, searchFromAbsoluteRoot)
endif endif
return targetNode return targetNode
endfunction endfunction
"FUNCTION: s:InitNerdTree(dir) {{{2 "FUNCTION: s:InitNerdTree(name) {{{2
"Initialized the NERD tree, where the root will be initialized with the given "Initialise the nerd tree for this tab. The tree will start in either the
"directory "given directory, or the directory associated with the given mark
" "
"Arg: "Args:
"dir: the dir to init the root with "name: the name of a mark or a directory
function! s:InitNerdTree(dir) function! s:InitNerdTree(name)
let dir = a:dir == '' ? expand('%:p:h') : a:dir let path = {}
if count(keys(s:GetMarks()), a:name)
let path = s:GetMarks()[a:name]
else
let dir = a:name == '' ? expand('%:p:h') : a:name
let dir = resolve(dir) let dir = resolve(dir)
try
let path = s:oPath.New(dir) let path = s:oPath.New(dir)
catch /NERDTree.Path.InvalidArguments/
if !path.isDirectory call s:Echo("No mark or directory found for: " . a:name)
call s:EchoWarning("Error reading: " . dir)
return return
endtry
if !path.isDirectory
let path = path.GetParent()
endif
endif endif
"if instructed to, then change the vim CWD to the dir the NERDTree is "if instructed to, then change the vim CWD to the dir the NERDTree is
@@ -1460,16 +1467,6 @@ function! s:InitNerdTree(dir)
call s:RenderView() call s:RenderView()
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0) call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
endfunction endfunction
"FUNCTION: s:InitNerdTreeFromMark(name) {{{2
"initialise a new NERD tree from the path associated with the given mark name
function! s:InitNerdTreeFromMark(name)
let target = s:GetMarks()[a:name]
if !target.isDirectory
let target = target.GetParent()
endif
call s:InitNerdTree(target.StrForOS(0))
endfunction
" Function: s:ReadMarks() {{{2 " Function: s:ReadMarks() {{{2
function! s:ReadMarks() function! s:ReadMarks()
if filereadable(g:NERDTreeMarksFile) if filereadable(g:NERDTreeMarksFile)