Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn invalid files #1365

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/nerdtree/tree_dir_node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ function! s:TreeDirNode._initChildren(silent)
endif

let invalidFilesFound = 0
let invalidFiles = []
for i in files
try
let path = g:NERDTreePath.New(i)
call self.createChild(path, 0)
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound += 1
let invalidFiles += [i]
endtry
endfor

Expand All @@ -437,7 +439,7 @@ function! s:TreeDirNode._initChildren(silent)
call nerdtree#echo('')

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

Expand All @@ -589,7 +593,7 @@ function! s:TreeDirNode.refresh()
call self.sortChildren()

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
endfunction
Expand Down