fix: skip normalizing empty file paths #1363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a quite niche Windows bug where quickly changing popup windows could cause Neo-tree to try and follow (and thus normalize) an
nil
file path. This causes an error message to be printed, despite not actually being an issue for Neo-tree.Essentially the problem is:
NuiInput
) closes, changing the active bufferneo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua
Line 105 in 7d3b020
toggleterm
floating window is opened (triggered from the previousNuiInput
byon_submit
) and changes the active buffer to be aterm://
path before the debounce timer finishesfollow_internal
function does not includeterm://
paths when callingmanager.get_path_to_reveal()
so it returnsnil
and passes that directly intonormalize_path
:neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua
Line 33 in 7d3b020
path
value is indexed here, but the function does not check fornil
(note the doc comment states the argument is astring
notstring?
):neo-tree.nvim/lua/neo-tree/utils/init.lua
Line 763 in 7d3b020
follow_internal
can gracefully exit early from an empty path here:neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua
Line 34 in 7d3b020
The check is only added after theM.is_windows
branch, so this will not change behavior for any non-Windows users. Windows users will have the exact same behavior (no file will be followed), just without the error message.See below comment.