Verify we haven't reached root when traversing cascade

This commit is contained in:
Łukasz Adamczak
2016-06-22 13:59:49 +02:00
parent c99312442b
commit 2924ab2071

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()
let childNodes = parent.getVisibleChildren()
if len(childNodes) == 1 && childNodes[0].path.isDirectory
let parent = parent.parent
else
break
endif
endwhile
call parent.close()
call b:NERDTree.render()
call parent.putCursorHere(0, 0)