Skip to content

Commit 59c39cb

Browse files
committed
fix(#2293): remove unnecessary git status during find file
1 parent 3cc698b commit 59c39cb

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

lua/nvim-tree/actions/finders/find-file.lua

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ local view = require "nvim-tree.view"
33
local utils = require "nvim-tree.utils"
44
local renderer = require "nvim-tree.renderer"
55
local core = require "nvim-tree.core"
6-
local reload = require "nvim-tree.explorer.reload"
76
local Iterator = require "nvim-tree.iterators.node-iterator"
87

98
local M = {}
@@ -30,10 +29,8 @@ function M.fn(path)
3029

3130
local profile = log.profile_start("find file %s", path_real)
3231

33-
-- we cannot wait for watchers to populate a new node
34-
if utils.get_node_from_path(path_real) == nil then
35-
reload.refresh_nodes_for_path(vim.fn.fnamemodify(path_real, ":h"))
36-
end
32+
-- force a re-expand when the node is not in the tree
33+
local node_present = utils.get_node_from_path(path_real) ~= nil
3734

3835
local line = core.get_nodes_starting_line()
3936

@@ -60,7 +57,7 @@ function M.fn(path)
6057
if not node.group_next then
6158
node.open = true
6259
end
63-
if #node.nodes == 0 then
60+
if #node.nodes == 0 or not node_present then
6461
core.get_explorer():expand(node)
6562
end
6663
end

lua/nvim-tree/explorer/reload.lua

-39
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ local live_filter = require "nvim-tree.live-filter"
77
local git = require "nvim-tree.git"
88
local log = require "nvim-tree.log"
99

10-
local NodeIterator = require "nvim-tree.iterators.node-iterator"
1110
local Watcher = require "nvim-tree.watcher"
1211

1312
local M = {}
@@ -178,44 +177,6 @@ function M.refresh_node(node, callback)
178177
end
179178
end
180179

181-
---Refresh contents and git status for all nodes to a path: actual directory and links
182-
---@param path string absolute path
183-
function M.refresh_nodes_for_path(path)
184-
local explorer = require("nvim-tree.core").get_explorer()
185-
if not explorer then
186-
return
187-
end
188-
189-
local profile = log.profile_start("refresh_nodes_for_path %s", path)
190-
191-
-- avoids cycles
192-
local absolute_paths_refreshed = {}
193-
194-
NodeIterator.builder({ explorer })
195-
:hidden()
196-
:recursor(function(node)
197-
if node.group_next then
198-
return { node.group_next }
199-
end
200-
if node.nodes then
201-
return node.nodes
202-
end
203-
end)
204-
:applier(function(node)
205-
local abs_contains = node.absolute_path and path:find(node.absolute_path, 1, true) == 1
206-
local link_contains = node.link_to and path:find(node.link_to, 1, true) == 1
207-
if abs_contains or link_contains then
208-
if not absolute_paths_refreshed[node.absolute_path] then
209-
absolute_paths_refreshed[node.absolute_path] = true
210-
M.refresh_node(node)
211-
end
212-
end
213-
end)
214-
:iterate()
215-
216-
log.profile_end(profile)
217-
end
218-
219180
function M.setup(opts)
220181
M.config = opts.renderer
221182
end

0 commit comments

Comments
 (0)