Merge pull request #720 from lifecrisis/issue526
BUGFIX: Repair opening and closing of cascades.
This commit is contained in:
commit
ab0a3a7c24
@ -59,7 +59,7 @@ Installation
|
|||||||
|
|
||||||
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
|
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
|
||||||
|
|
||||||
Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`.
|
Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERDTree.txt`.
|
||||||
|
|
||||||
|
|
||||||
#### [apt-vim](https://github.com/egalpin/apt-vim)
|
#### [apt-vim](https://github.com/egalpin/apt-vim)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*NERD_tree.txt* A tree explorer plugin that owns your momma!
|
*NERDTree.txt* A tree explorer plugin that owns your momma!
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,9 +45,14 @@ function! s:TreeDirNode.addChild(treenode, inOrder)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.close() {{{1
|
" FUNCTION: TreeDirNode.close() {{{1
|
||||||
" Closes this directory
|
" Mark this TreeDirNode as closed.
|
||||||
function! s:TreeDirNode.close()
|
function! s:TreeDirNode.close()
|
||||||
let self.isOpen = 0
|
|
||||||
|
" Close all directories in this directory node's cascade. This is
|
||||||
|
" necessary to ensure consistency when cascades are rendered.
|
||||||
|
for l:dirNode in self.getCascade()
|
||||||
|
let l:dirNode.isOpen = 0
|
||||||
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.closeChildren() {{{1
|
" FUNCTION: TreeDirNode.closeChildren() {{{1
|
||||||
@ -78,19 +83,29 @@ function! s:TreeDirNode.createChild(path, inOrder)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.displayString() {{{1
|
" FUNCTION: TreeDirNode.displayString() {{{1
|
||||||
unlet s:TreeDirNode.displayString
|
" Assemble and return a string that can represent this TreeDirNode object in
|
||||||
|
" the NERDTree window.
|
||||||
function! s:TreeDirNode.displayString()
|
function! s:TreeDirNode.displayString()
|
||||||
let cascade = self.getCascade()
|
let l:result = ''
|
||||||
let rv = ""
|
|
||||||
for node in cascade
|
" Build a label that identifies this TreeDirNode.
|
||||||
let rv = rv . node.path.displayString()
|
let l:label = ''
|
||||||
|
let l:cascade = self.getCascade()
|
||||||
|
for l:dirNode in l:cascade
|
||||||
|
let l:label .= l:dirNode.path.displayString()
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable
|
" Select the appropriate open/closed status indicator symbol.
|
||||||
|
if l:cascade[-1].isOpen
|
||||||
|
let l:symbol = g:NERDTreeDirArrowCollapsible
|
||||||
|
else
|
||||||
|
let l:symbol = g:NERDTreeDirArrowExpandable
|
||||||
|
endif
|
||||||
|
|
||||||
let flags = cascade[-1].path.flagSet.renderToString()
|
let l:flags = l:cascade[-1].path.flagSet.renderToString()
|
||||||
|
|
||||||
return sym . ' ' . flags . rv
|
let l:result = l:symbol . ' ' . l:flags . l:label
|
||||||
|
return l:result
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.findNode(path) {{{1
|
" FUNCTION: TreeDirNode.findNode(path) {{{1
|
||||||
@ -400,25 +415,39 @@ function! s:TreeDirNode.New(path, nerdtree)
|
|||||||
return newTreeNode
|
return newTreeNode
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.open([opts]) {{{1
|
" FUNCTION: TreeDirNode.open([options]) {{{1
|
||||||
" Open the dir in the current tree or in a new tree elsewhere.
|
" Open this directory node in the current tree or elsewhere if special options
|
||||||
"
|
" are provided. Return 0 if options were processed. Otherwise, return the
|
||||||
" If opening in the current tree, return the number of cached nodes.
|
" number of new cached nodes.
|
||||||
unlet s:TreeDirNode.open
|
|
||||||
function! s:TreeDirNode.open(...)
|
function! s:TreeDirNode.open(...)
|
||||||
let opts = a:0 ? a:1 : {}
|
let l:options = a:0 ? a:1 : {}
|
||||||
|
|
||||||
if has_key(opts, 'where') && !empty(opts['where'])
|
" If special options were specified, process them and return.
|
||||||
let opener = g:NERDTreeOpener.New(self.path, opts)
|
if has_key(l:options, 'where') && !empty(l:options['where'])
|
||||||
call opener.open(self)
|
let l:opener = g:NERDTreeOpener.New(self.path, l:options)
|
||||||
else
|
call l:opener.open(self)
|
||||||
let self.isOpen = 1
|
|
||||||
if self.children ==# []
|
|
||||||
return self._initChildren(0)
|
|
||||||
else
|
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Open any ancestors of this node that render within the same cascade.
|
||||||
|
let l:parent = self.parent
|
||||||
|
while !empty(l:parent) && !l:parent.isRoot()
|
||||||
|
if index(l:parent.getCascade(), self) >= 0
|
||||||
|
let l:parent.isOpen = 1
|
||||||
|
let l:parent = l:parent.parent
|
||||||
|
else
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
let self.isOpen = 1
|
||||||
|
|
||||||
|
let l:numChildrenCached = 0
|
||||||
|
if empty(self.children)
|
||||||
|
let l:numChildrenCached = self._initChildren(0)
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:numChildrenCached
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.openAlong([opts]) {{{1
|
" FUNCTION: TreeDirNode.openAlong([opts]) {{{1
|
||||||
@ -463,35 +492,16 @@ function! s:TreeDirNode._openInNewTab()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.openRecursively() {{{1
|
" FUNCTION: TreeDirNode.openRecursively() {{{1
|
||||||
" Opens this treenode and all of its children whose paths arent 'ignored'
|
" Open this directory node and any descendant directory nodes whose pathnames
|
||||||
" because of the file filters.
|
" are not ignored.
|
||||||
"
|
|
||||||
" This method is actually a wrapper for the OpenRecursively2 method which does
|
|
||||||
" the work.
|
|
||||||
function! s:TreeDirNode.openRecursively()
|
function! s:TreeDirNode.openRecursively()
|
||||||
call self._openRecursively2(1)
|
silent call self.open()
|
||||||
endfunction
|
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode._openRecursively2() {{{1
|
for l:child in self.children
|
||||||
" Opens this all children of this treenode recursively if either:
|
if l:child.path.isDirectory && !l:child.path.ignore(l:child.getNerdtree())
|
||||||
" *they arent filtered by file filters
|
call l:child.openRecursively()
|
||||||
" *a:forceOpen is 1
|
|
||||||
"
|
|
||||||
" Args:
|
|
||||||
" forceOpen: 1 if this node should be opened regardless of file filters
|
|
||||||
function! s:TreeDirNode._openRecursively2(forceOpen)
|
|
||||||
if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen
|
|
||||||
let self.isOpen = 1
|
|
||||||
if self.children ==# []
|
|
||||||
call self._initChildren(1)
|
|
||||||
endif
|
|
||||||
|
|
||||||
for i in self.children
|
|
||||||
if i.path.isDirectory ==# 1
|
|
||||||
call i._openRecursively2(0)
|
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.refresh() {{{1
|
" FUNCTION: TreeDirNode.refresh() {{{1
|
||||||
|
Loading…
Reference in New Issue
Block a user