rework the cascading slightly to correctly show open/closed dir arrows
This commit is contained in:
parent
2cef8bb602
commit
af39458989
@ -76,19 +76,15 @@ endfunction
|
|||||||
"FUNCTION: TreeDirNode.displayString() {{{1
|
"FUNCTION: TreeDirNode.displayString() {{{1
|
||||||
unlet s:TreeDirNode.displayString
|
unlet s:TreeDirNode.displayString
|
||||||
function! s:TreeDirNode.displayString()
|
function! s:TreeDirNode.displayString()
|
||||||
let vc = self.getVisibleChildren()
|
let cascade = self.getCascade()
|
||||||
if len(vc) != 1
|
let rv = ""
|
||||||
return self.path.displayString()
|
for node in cascade
|
||||||
endif
|
let rv = rv . node.path.displayString()
|
||||||
|
endfor
|
||||||
|
|
||||||
let visChild = vc[0]
|
let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable
|
||||||
|
|
||||||
"TODO: optimize
|
return sym . ' ' . rv
|
||||||
if !visChild.path.isDirectory
|
|
||||||
return self.path.displayString()
|
|
||||||
endif
|
|
||||||
|
|
||||||
return self.path.getLastPathComponent(1) . visChild.displayString()
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.findNode(path) {{{1
|
"FUNCTION: TreeDirNode.findNode(path) {{{1
|
||||||
@ -116,6 +112,33 @@ function! s:TreeDirNode.findNode(path)
|
|||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: TreeDirNode.getCascade() {{{1
|
||||||
|
"Return an array of dir nodes (starting from self) that can be cascade opened.
|
||||||
|
function! s:TreeDirNode.getCascade()
|
||||||
|
|
||||||
|
let rv = [self]
|
||||||
|
let node = self
|
||||||
|
|
||||||
|
while 1
|
||||||
|
let vc = node.getVisibleChildren()
|
||||||
|
if len(vc) != 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
let visChild = vc[0]
|
||||||
|
|
||||||
|
"TODO: optimize
|
||||||
|
if !visChild.path.isDirectory
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(rv, visChild)
|
||||||
|
let node = visChild
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return rv
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getChildCount() {{{1
|
"FUNCTION: TreeDirNode.getChildCount() {{{1
|
||||||
"Returns the number of children this node has
|
"Returns the number of children this node has
|
||||||
function! s:TreeDirNode.getChildCount()
|
function! s:TreeDirNode.getChildCount()
|
||||||
|
@ -337,10 +337,7 @@ function! s:TreeFileNode._renderToString(depth, drawText)
|
|||||||
|
|
||||||
let treeParts = repeat(' ', a:depth - 1)
|
let treeParts = repeat(' ', a:depth - 1)
|
||||||
|
|
||||||
if self.path.isDirectory
|
if !self.path.isDirectory
|
||||||
let sym = self.isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable
|
|
||||||
let treeParts = treeParts . sym . ' '
|
|
||||||
else
|
|
||||||
let treeParts = treeParts . ' '
|
let treeParts = treeParts . ' '
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user