Merge pull request #591 from czak/cascade-close-fix
Fix upward traversal when closing a cascade
This commit is contained in:
commit
2e2b649232
@ -187,17 +187,17 @@ endfunction
|
|||||||
" closes the parent dir of the current node
|
" closes the parent dir of the current node
|
||||||
function! s:closeCurrentDir(node)
|
function! s:closeCurrentDir(node)
|
||||||
let parent = a:node.parent
|
let parent = a:node.parent
|
||||||
|
while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot()
|
||||||
|
let childNodes = parent.getVisibleChildren()
|
||||||
|
if len(childNodes) == 1 && childNodes[0].path.isDirectory
|
||||||
|
let parent = parent.parent
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
if parent ==# {} || parent.isRoot()
|
if parent ==# {} || parent.isRoot()
|
||||||
call nerdtree#echo("cannot close tree root")
|
call nerdtree#echo("cannot close tree root")
|
||||||
else
|
else
|
||||||
while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot()
|
|
||||||
if parent.parent.getVisibleChildCount() == 1
|
|
||||||
call parent.close()
|
|
||||||
let parent = parent.parent
|
|
||||||
else
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
call parent.close()
|
call parent.close()
|
||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
call parent.putCursorHere(0, 0)
|
call parent.putCursorHere(0, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user