Merge pull request #251 from pendulm/master

fix typo and smart close single child directory
This commit is contained in:
Martin Grenfell 2014-06-27 19:25:48 +01:00
commit 0928b5b026
4 changed files with 20 additions and 11 deletions

View File

@ -1068,9 +1068,17 @@ function! s:closeCurrentDir(node)
if parent ==# {} || parent.isRoot()
call nerdtree#echo("cannot close tree root")
else
call a:node.parent.close()
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 nerdtree#renderView()
call a:node.parent.putCursorHere(0, 0)
call parent.putCursorHere(0, 0)
endif
endfunction

View File

@ -676,8 +676,8 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
+ ~ chars when displaying directories.
|'NERDTreeCasadeOpenSingleChildDir'|
Casade open while selected directory has only
|'NERDTreeCascadeOpenSingleChildDir'|
Cascade open while selected directory has only
one child that also is a directory.
|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove
@ -1011,16 +1011,17 @@ option: >
<
------------------------------------------------------------------------------
*'NERDTreeCasadeOpenSingleChildDir'*
*'NERDTreeCascadeOpenSingleChildDir'*
Values: 0 or 1
Default: 1.
When opening dir nodes, this option tells NERDTree to recursively open dirs
that have only one child which is also a dir. NERDTree will stop when it finds
a dir that contains anything but another single dir. This option may be useful
for Java projects. Use one of the follow lines to set this option: >
let NERDTreeCasadeOpenSingleChildDir=0
let NERDTreeCasadeOpenSingleChildDir=1
a dir that contains anything but another single dir. Set this option on also
cause NERDTree close parent dir intelligent. This option may be useful for Java
projects. Use one of the follow lines to set this option: >
let NERDTreeCascadeOpenSingleChildDir=0
let NERDTreeCascadeOpenSingleChildDir=1
<
------------------------------------------------------------------------------

View File

@ -500,7 +500,7 @@ function! s:TreeDirNode.toggleOpen(...)
if self.isOpen ==# 1
call self.close()
else
if g:NERDTreeCasadeOpenSingleChildDir == 0
if g:NERDTreeCascadeOpenSingleChildDir == 0
call self.open(opts)
else
call self.openAlong(opts)

View File

@ -69,7 +69,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows())
call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']