refactor TreeDirNode.reveal slightly

This commit is contained in:
Martin Grenfell
2015-11-16 09:35:31 +00:00
parent 449f2c77ed
commit 0b966aa23a
2 changed files with 12 additions and 6 deletions

View File

@@ -289,7 +289,9 @@ function! s:findAndRevealPath()
endif
endif
call g:NERDTree.CursorToTreeWin()
call b:NERDTreeRoot.reveal(p)
let node = b:NERDTreeRoot.reveal(p)
call b:NERDTree.render()
call node.putCursorHere(1,0)
if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden

View File

@@ -460,7 +460,10 @@ endfunction
"FUNCTION: TreeDirNode.reveal(path) {{{1
"reveal the given path, i.e. cache and open all treenodes needed to display it
"in the UI
function! s:TreeDirNode.reveal(path)
"Returns the revealed node
function! s:TreeDirNode.reveal(path, ...)
let opts = a:0 ? a:1 : {}
if !a:path.isUnder(self.path)
throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str()
endif
@@ -469,9 +472,10 @@ function! s:TreeDirNode.reveal(path)
if self.path.equals(a:path.getParent())
let n = self.findNode(a:path)
call b:NERDTree.render()
call n.putCursorHere(1,0)
return
if has_key(opts, "open")
call n.open()
endif
return n
endif
let p = a:path
@@ -480,7 +484,7 @@ function! s:TreeDirNode.reveal(path)
endwhile
let n = self.findNode(p)
call n.reveal(a:path)
return n.reveal(a:path, opts)
endfunction
"FUNCTION: TreeDirNode.removeChild(treenode) {{{1