mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 03:43:50 -05:00
Rewrite getCascade recursively
This commit is contained in:
@@ -117,28 +117,14 @@ endfunction
|
|||||||
"FUNCTION: TreeDirNode.getCascade() {{{1
|
"FUNCTION: TreeDirNode.getCascade() {{{1
|
||||||
"Return an array of dir nodes (starting from self) that can be cascade opened.
|
"Return an array of dir nodes (starting from self) that can be cascade opened.
|
||||||
function! s:TreeDirNode.getCascade()
|
function! s:TreeDirNode.getCascade()
|
||||||
|
if !self.isCascadable()
|
||||||
let rv = [self]
|
return [self]
|
||||||
let node = self
|
|
||||||
|
|
||||||
while 1
|
|
||||||
let vc = node.getVisibleChildren()
|
|
||||||
if len(vc) != 1
|
|
||||||
break
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let vc = self.getVisibleChildren()
|
||||||
let visChild = vc[0]
|
let visChild = vc[0]
|
||||||
|
|
||||||
"TODO: optimize
|
return [self] + visChild.getCascade()
|
||||||
if !visChild.path.isDirectory
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(rv, visChild)
|
|
||||||
let node = visChild
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return rv
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getChildCount() {{{1
|
"FUNCTION: TreeDirNode.getChildCount() {{{1
|
||||||
|
|||||||
Reference in New Issue
Block a user