Skip to content

1961 cycle detection on refresh #1996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2023
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
12 changes: 9 additions & 3 deletions lua/nvim-tree/explorer/reload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ function M.refresh_nodes_for_path(path)

local profile = log.profile_start("refresh_nodes_for_path %s", path)

-- avoids cycles
local paths_refreshed = {}

NodeIterator.builder({ explorer })
:hidden()
:recursor(function(node)
Expand All @@ -177,10 +180,13 @@ function M.refresh_nodes_for_path(path)
end
end)
:applier(function(node)
local abs_contains = node.absolute_path and path:match("^" .. node.absolute_path)
local link_contains = node.link_to and path:match("^" .. node.link_to)
local abs_contains = node.absolute_path and path:find(node.absolute_path, 1, true) ~= 1
local link_contains = node.link_to and path:find(node.link_to, 1, true) ~= 1
if abs_contains or link_contains then
M.refresh_node(node)
if not paths_refreshed[node.absolute_path] then
paths_refreshed[node.absolute_path] = true
M.refresh_node(node)
end
end
end)
:iterate()
Expand Down