Skip to content

Commit 0e02a06

Browse files
committed
fix(#1731): find-file locks/profiles on real path, reloads when watchers disabled
1 parent 266b616 commit 0e02a06

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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

+19-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ 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 reloaders = require "nvim-tree.actions.reloaders.reloaders"
67
local Iterator = require "nvim-tree.iterators.node-iterator"
78

89
local M = {}
@@ -12,18 +13,27 @@ local running = {}
1213
---Find a path in the tree, expand it and focus it
1314
---@param fname string full path
1415
function M.fn(fname)
15-
if running[fname] or not core.get_explorer() then
16+
if not core.get_explorer() then
1617
return
1718
end
18-
running[fname] = true
1919

20-
local ps = log.profile_start("find file %s", fname)
2120
-- always match against the real path
2221
local fname_real = vim.loop.fs_realpath(fname)
2322
if not fname_real then
2423
return
2524
end
2625

26+
if running[fname_real] then
27+
return
28+
end
29+
running[fname_real] = true
30+
31+
local ps = log.profile_start("find file %s", fname_real)
32+
33+
if not M.filesystem_watchers_enabled then
34+
reloaders.reload_explorer()
35+
end
36+
2737
local line = core.get_nodes_starting_line()
2838

2939
local absolute_paths_searched = {}
@@ -60,9 +70,13 @@ function M.fn(fname)
6070
view.set_cursor { line, 0 }
6171
end
6272

63-
running[fname] = false
73+
running[fname_real] = false
74+
75+
log.profile_end(ps, "find file %s", fname_real)
76+
end
6477

65-
log.profile_end(ps, "find file %s", fname)
78+
function M.setup(opts)
79+
M.filesystem_watchers_enabled = opts.filesystem_watchers.enabled
6680
end
6781

6882
return M

lua/nvim-tree/actions/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ local DEFAULT_MAPPING_CONFIG = {
385385
}
386386

387387
function M.setup(opts)
388+
require("nvim-tree.actions.finders.find-file").setup(opts)
388389
require("nvim-tree.actions.fs.trash").setup(opts)
389390
require("nvim-tree.actions.node.system-open").setup(opts)
390391
require("nvim-tree.actions.node.file-popup").setup(opts)

0 commit comments

Comments
 (0)