Skip to content

Commit a4dd5ad

Browse files
fix(#2906): resource leak on populate children (#2907)
Don't collect reason statistics for reason none Co-authored-by: Alexander Courtis <[email protected]>
1 parent b652dbd commit a4dd5ad

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

lua/nvim-tree/explorer/explore.lua

+17-15
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,24 @@ local function populate_children(handle, cwd, node, git_status, parent)
4646
local type = stat and stat.type or nil
4747

4848
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
49-
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
50-
local child = nil
51-
if type == "directory" and vim.loop.fs_access(abs, "R") then
52-
child = builders.folder(node, abs, name, stat)
53-
elseif type == "file" then
54-
child = builders.file(node, abs, name, stat)
55-
elseif type == "link" then
56-
local link = builders.link(node, abs, name, stat)
57-
if link.link_to ~= nil then
58-
child = link
49+
if filter_reason == FILTER_REASON.none then
50+
if not nodes_by_path[abs] then
51+
local child = nil
52+
if type == "directory" and vim.loop.fs_access(abs, "R") then
53+
child = builders.folder(node, abs, name, stat)
54+
elseif type == "file" then
55+
child = builders.file(node, abs, name, stat)
56+
elseif type == "link" then
57+
local link = builders.link(node, abs, name, stat)
58+
if link.link_to ~= nil then
59+
child = link
60+
end
61+
end
62+
if child then
63+
table.insert(node.nodes, child)
64+
nodes_by_path[child.absolute_path] = true
65+
explorer_node.update_git_status(child, node_ignored, git_status)
5966
end
60-
end
61-
if child then
62-
table.insert(node.nodes, child)
63-
nodes_by_path[child.absolute_path] = true
64-
explorer_node.update_git_status(child, node_ignored, git_status)
6567
end
6668
else
6769
for reason, value in pairs(FILTER_REASON) do

0 commit comments

Comments
 (0)