mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-29 04:33:40 +08:00
Fix the "TreeDirNode.open()" method
Issues #547 and #526 reported a problem with the "open()" method in the "TreeDirNode" class. Specifically, opening a cascade in the NERDTree will perform the opening operation on the tail of the cascade. This is a problem when other operations (such as the "u" mapping) close intermediate cascaded directories, which causes opening the tail to have no effect (other than toggling the arrow). Here, the "open()" method was modified to open all directories in a cascade whenever the tail is opened. This is the only reasonable fix for this type of problem. Fixes #547 and fixes #526.
This commit is contained in:
parent
18f04e0824
commit
8660541333
|
@ -410,25 +410,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 l:parent != b:NERDTree.root && !empty(l:parent)
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user