Add two more disqualifications for isCascadable(). (#914)

* Add two more disqualifications for isCascadable().

A directory that is bookmarked or that is a symlink to another location
has trailing text indicating so. This extra text causes problem when
cascading with a directory underneath it, so disable it in this case.

* Add comments to explain the new exclusions for bookmarks and symlinks.
This commit is contained in:
Phil Runninger 2018-11-20 13:33:23 -05:00 committed by GitHub
parent f406af39cf
commit 370eb5bcb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -370,12 +370,26 @@ function! s:TreeDirNode.hasVisibleChildren()
endfunction endfunction
" FUNCTION: TreeDirNode.isCascadable() {{{1 " FUNCTION: TreeDirNode.isCascadable() {{{1
" true if this dir has only one visible child - which is also a dir " true if this dir has only one visible child that is also a dir
" false if this dir is bookmarked or symlinked. Why? Two reasons:
" 1. If cascaded, we don't know which dir is bookmarked or is a symlink.
" 2. If the parent is a symlink or is bookmarked, you end up with unparsable
" text, and NERDTree cannot get the path of any child node.
function! s:TreeDirNode.isCascadable() function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir == 0 if g:NERDTreeCascadeSingleChildDir == 0
return 0 return 0
endif endif
if self.path.isSymLink
return 0
endif
for i in g:NERDTreeBookmark.Bookmarks()
if i.path.equals(self.path)
return 0
endif
endfor
let c = self.getVisibleChildren() let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory return len(c) == 1 && c[0].path.isDirectory
endfunction endfunction