Skip to content
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
4 changes: 2 additions & 2 deletions lua/nvim-tree/explorer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

if filter_reason == value and type(node.hidden_stats[reason]) == "number" then
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
end
end
Expand Down