mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
merge InitNerdTreeFromMark into InitNerdTree
This commit is contained in:
@@ -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 = {}
|
||||||
let dir = resolve(dir)
|
if count(keys(s:GetMarks()), a:name)
|
||||||
|
let path = s:GetMarks()[a:name]
|
||||||
let path = s:oPath.New(dir)
|
else
|
||||||
|
let dir = a:name == '' ? expand('%:p:h') : a:name
|
||||||
if !path.isDirectory
|
let dir = resolve(dir)
|
||||||
call s:EchoWarning("Error reading: " . dir)
|
try
|
||||||
return
|
let path = s:oPath.New(dir)
|
||||||
|
catch /NERDTree.Path.InvalidArguments/
|
||||||
|
call s:Echo("No mark or directory found for: " . a:name)
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user