Merge pull request #591 from czak/cascade-close-fix

Fix upward traversal when closing a cascade
This commit is contained in:
Martin Grenfell 2016-06-23 13:37:52 +01:00 committed by GitHub
commit 2e2b649232

View File

@ -187,17 +187,17 @@ endfunction
" closes the parent dir of the current node
function! s:closeCurrentDir(node)
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()
call nerdtree#echo("cannot close tree root")
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 b:NERDTree.render()
call parent.putCursorHere(0, 0)