Skip to content

Commit ea55ef1

Browse files
authored
refactor(#2837): multi instance reload (#2885)
* refactor(#2837): multi instance reload * refactor(#2837): multi instance reload
1 parent 43c3c36 commit ea55ef1

File tree

6 files changed

+282
-290
lines changed

6 files changed

+282
-290
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ local log = require "nvim-tree.log"
22
local view = require "nvim-tree.view"
33
local utils = require "nvim-tree.utils"
44
local renderer = require "nvim-tree.renderer"
5-
local reload = require "nvim-tree.explorer.reload"
65
local core = require "nvim-tree.core"
76
local Iterator = require "nvim-tree.iterators.node-iterator"
87

@@ -13,7 +12,8 @@ local running = {}
1312
---Find a path in the tree, expand it and focus it
1413
---@param path string relative or absolute
1514
function M.fn(path)
16-
if not core.get_explorer() or not view.is_visible() then
15+
local explorer = core.get_explorer()
16+
if not explorer or not view.is_visible() then
1717
return
1818
end
1919

@@ -32,7 +32,7 @@ function M.fn(path)
3232

3333
-- refresh the contents of all parents, expanding groups as needed
3434
if utils.get_node_from_path(path_real) == nil then
35-
reload.refresh_parent_nodes_for_path(vim.fn.fnamemodify(path_real, ":h"))
35+
explorer:refresh_parent_nodes_for_path(vim.fn.fnamemodify(path_real, ":h"))
3636
end
3737

3838
local line = core.get_nodes_starting_line()

lua/nvim-tree/actions/reloaders.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
local git = require "nvim-tree.git"
22
local view = require "nvim-tree.view"
33
local renderer = require "nvim-tree.renderer"
4-
local explorer_module = require "nvim-tree.explorer"
54
local core = require "nvim-tree.core"
65
local explorer_node = require "nvim-tree.explorer.node"
76
local Iterator = require "nvim-tree.iterators.node-iterator"
87

98
local M = {}
109

11-
---@param node Explorer|nil
10+
---@param explorer Explorer|nil
1211
---@param projects table
13-
local function refresh_nodes(node, projects)
14-
Iterator.builder({ node })
12+
local function refresh_nodes(explorer, projects)
13+
Iterator.builder({ explorer })
1514
:applier(function(n)
1615
if n.nodes then
1716
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path)
18-
explorer_module.reload(n, projects[toplevel] or {})
17+
if explorer then
18+
explorer:reload(n, projects[toplevel] or {})
19+
end
1920
end
2021
end)
2122
:recursor(function(n)

lua/nvim-tree/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function M.init(foldername)
1616
if TreeExplorer then
1717
TreeExplorer:destroy()
1818
end
19-
TreeExplorer = explorer.Explorer.new(foldername)
19+
TreeExplorer = explorer:new(foldername)
2020
if not first_init_done then
2121
events._dispatch_ready()
2222
first_init_done = true

0 commit comments

Comments
 (0)