Skip to content

Commit 8d46f98

Browse files
committed
abort iteration when fs-event-incapable
Fixes nvim-tree#2866. The original code, while detecting whether Windows NT allows the dir to be iterated through, will go to the other branch of the if...else... statement, which is intended for cases when filter_reason is not none. Simply moving `is_fs_event_capable` into the first branch should solve the problem.
1 parent ad0b95d commit 8d46f98

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
@@ -40,22 +40,24 @@ local function populate_children(handle, cwd, node, git_status, parent)
4040
---@type uv.fs_stat.result|nil
4141
local stat = vim.loop.fs_stat(abs)
4242
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
43-
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] and Watcher.is_fs_event_capable(abs) then
44-
local child = nil
45-
if t == "directory" and vim.loop.fs_access(abs, "R") then
46-
child = builders.folder(node, abs, name, stat)
47-
elseif t == "file" then
48-
child = builders.file(node, abs, name, stat)
49-
elseif t == "link" then
50-
local link = builders.link(node, abs, name, stat)
51-
if link.link_to ~= nil then
52-
child = link
43+
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
44+
if Watcher.is_fs_event_capable(abs) then
45+
local child = nil
46+
if t == "directory" and vim.loop.fs_access(abs, "R") then
47+
child = builders.folder(node, abs, name, stat)
48+
elseif t == "file" then
49+
child = builders.file(node, abs, name, stat)
50+
elseif t == "link" then
51+
local link = builders.link(node, abs, name, stat)
52+
if link.link_to ~= nil then
53+
child = link
54+
end
55+
end
56+
if child then
57+
table.insert(node.nodes, child)
58+
nodes_by_path[child.absolute_path] = true
59+
explorer_node.update_git_status(child, node_ignored, git_status)
5360
end
54-
end
55-
if child then
56-
table.insert(node.nodes, child)
57-
nodes_by_path[child.absolute_path] = true
58-
explorer_node.update_git_status(child, node_ignored, git_status)
5961
end
6062
else
6163
for reason, value in pairs(FILTER_REASON) do

0 commit comments

Comments
 (0)