mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-25 17:57:24 +08:00
refactor the Refresh() method for tree nodes
create a oFileTreeNode#Refresh() and make sure that Refresh() is always called for dir nodes
This commit is contained in:
parent
a111af5361
commit
1571274aec
|
@ -348,6 +348,10 @@ function! s:oTreeFileNode.New(path) dict
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oTreeFileNode.Refresh {{{3
|
||||
function! s:oTreeFileNode.Refresh() dict
|
||||
call self.path.Refresh()
|
||||
endfunction
|
||||
"FUNCTION: oTreeFileNode.Rename {{{3
|
||||
"Calls the rename method for this nodes path obj
|
||||
function! s:oTreeFileNode.Rename(newName) dict
|
||||
|
@ -701,11 +705,15 @@ function! s:oTreeDirNode.OpenRecursively2(forceOpen) dict
|
|||
endfunction
|
||||
|
||||
"FUNCTION: oTreeDirNode.Refresh {{{3
|
||||
unlet s:oTreeDirNode.Refresh
|
||||
function! s:oTreeDirNode.Refresh() dict
|
||||
call self.path.Refresh()
|
||||
|
||||
"if this node was ever opened, refresh its children
|
||||
if self.isOpen || !empty(self.children)
|
||||
"go thru all the files/dirs under this node
|
||||
let newChildNodes = []
|
||||
let invalidFilesFound = 0
|
||||
|
||||
"go thru all the files/dirs under this node
|
||||
let dir = self.path
|
||||
let filesStr = globpath(dir.StrForGlob(), '*') . "\n" . globpath(dir.StrForGlob(), '.*')
|
||||
let files = split(filesStr, "\n")
|
||||
|
@ -717,17 +725,7 @@ function! s:oTreeDirNode.Refresh() dict
|
|||
let path = s:oPath.New(i)
|
||||
let newNode = self.GetChild(path)
|
||||
if newNode != {}
|
||||
|
||||
"if the existing node is a dir can be refreshed then
|
||||
"refresh it
|
||||
if newNode.path.isDirectory && (!empty(newNode.children) || newNode.isOpen == 1)
|
||||
call newNode.Refresh()
|
||||
|
||||
"if we have a filenode then refresh the path
|
||||
elseif newNode.path.isDirectory == 0
|
||||
call newNode.path.Refresh()
|
||||
endif
|
||||
|
||||
call add(newChildNodes, newNode)
|
||||
|
||||
"the node doesnt exist so create it
|
||||
|
@ -751,6 +749,7 @@ function! s:oTreeDirNode.Refresh() dict
|
|||
if invalidFilesFound
|
||||
call s:EchoWarning("some files could not be loaded into the NERD tree")
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: oTreeDirNode.RemoveChild {{{3
|
||||
|
|
Loading…
Reference in New Issue
Block a user