fix: arithmetic on nil value error on first git project open#3064
Merged
alex-courtis merged 3 commits intonvim-tree:masterfrom Feb 9, 2025
Merged
fix: arithmetic on nil value error on first git project open#3064alex-courtis merged 3 commits intonvim-tree:masterfrom
alex-courtis merged 3 commits intonvim-tree:masterfrom
Conversation
alex-courtis
reviewed
Feb 3, 2025
| end | ||
| else | ||
| for reason, value in pairs(FILTER_REASON) do | ||
| if filter_reason == value then |
Member
There was a problem hiding this comment.
It looks like node.hidden_stats could still be nil, as it's an optional member.
How about something really defensive like:
diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua
index 0fdd46a..c42ffe0 100644
--- a/lua/nvim-tree/explorer/init.lua
+++ b/lua/nvim-tree/explorer/init.lua
@@ -389,9 +389,9 @@ function Explorer:populate_children(handle, cwd, node, project, parent)
nodes_by_path[child.absolute_path] = true
child:update_git_status(node_ignored, project)
end
- else
+ elseif node.hidden_stats then
for reason, value in pairs(FILTER_REASON) do
- if filter_reason == value then
+ if filter_reason == value and type(node.hidden_stats[reason]) == "number" then
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
end
end
Contributor
Author
There was a problem hiding this comment.
Implemented it and it works for me as well.
I only have this issue on windows so this defensive version might be better to not break anything on linux.
alex-courtis
approved these changes
Feb 8, 2025
Member
alex-courtis
left a comment
There was a problem hiding this comment.
Many thanks for your contribution!
I'm glad you were able to test windows.
Contributor
Author
|
No problem, was just a small fix for myself anyways :) |
Member
|
Apologies; I didn't press the merge button. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When opening neovim in a directory with a git repo for the first time after PC reboot, I always got this error message:
This small change fixes it for me. I don't looked into the code all that deep, so maybe there is a better fix.
On a quick scim through the Issues I didn't find any matching Issue, maybe I overlooked it.