Warn about invalid files not loaded on-refresh

This commit is contained in:
rzvxa 2023-09-03 03:01:39 +03:30 committed by Caleb Maclennan
parent aedd0653ad
commit 32168889bd

View File

@ -566,6 +566,7 @@ function! s:TreeDirNode.refresh()
let files = self._glob('*', 1) + self._glob('.*', 0) let files = self._glob('*', 1) + self._glob('.*', 0)
let newChildNodes = [] let newChildNodes = []
let invalidFilesFound = 0 let invalidFilesFound = 0
let invalidFiles = []
for i in files for i in files
try try
"create a new path and see if it exists in this nodes children "create a new path and see if it exists in this nodes children
@ -582,7 +583,8 @@ function! s:TreeDirNode.refresh()
call add(newChildNodes, newNode) call add(newChildNodes, newNode)
endif endif
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound = 1 let invalidFilesFound += 1
let invalidFiles += [i]
endtry endtry
endfor endfor
@ -591,7 +593,7 @@ function! s:TreeDirNode.refresh()
call self.sortChildren() call self.sortChildren()
if invalidFilesFound if invalidFilesFound
call nerdtree#echoWarning('some files could not be loaded into the NERD tree') call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', '))
endif endif
endif endif
endfunction endfunction