Skip to content

Commit 2104786

Browse files
authored
fix(#2868): windows: do not visit unenumerable directories such as Application Data (#2874)
1 parent ad0b95d commit 2104786

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

Diff for: lua/nvim-tree/explorer/explore.lua

+30-27
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,40 @@ local function populate_children(handle, cwd, node, git_status, parent)
3535
end
3636

3737
local abs = utils.path_join { cwd, name }
38-
local profile = log.profile_start("explore populate_children %s", abs)
39-
40-
---@type uv.fs_stat.result|nil
41-
local stat = vim.loop.fs_stat(abs)
42-
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
38+
39+
if Watcher.is_fs_event_capable(abs) then
40+
local profile = log.profile_start("explore populate_children %s", abs)
41+
42+
---@type uv.fs_stat.result|nil
43+
local stat = vim.loop.fs_stat(abs)
44+
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
45+
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
46+
local child = nil
47+
if t == "directory" and vim.loop.fs_access(abs, "R") then
48+
child = builders.folder(node, abs, name, stat)
49+
elseif t == "file" then
50+
child = builders.file(node, abs, name, stat)
51+
elseif t == "link" then
52+
local link = builders.link(node, abs, name, stat)
53+
if link.link_to ~= nil then
54+
child = link
55+
end
5356
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)
59-
end
60-
else
61-
for reason, value in pairs(FILTER_REASON) do
62-
if filter_reason == value then
63-
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
57+
if child then
58+
table.insert(node.nodes, child)
59+
nodes_by_path[child.absolute_path] = true
60+
explorer_node.update_git_status(child, node_ignored, git_status)
61+
end
62+
else
63+
for reason, value in pairs(FILTER_REASON) do
64+
if filter_reason == value then
65+
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
66+
end
6467
end
6568
end
66-
end
6769

68-
log.profile_end(profile)
70+
log.profile_end(profile)
71+
end
6972
end
7073
end
7174

0 commit comments

Comments
 (0)