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
endif endif
call g:NERDTree.CursorToTreeWin() 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() if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden let g:NERDTreeShowHidden = showhidden

View File

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