Skip to content

Commit

Permalink
refactor(#2837): multi instance reload (#2885)
Browse files Browse the repository at this point in the history
* refactor(#2837): multi instance reload

* refactor(#2837): multi instance reload
  • Loading branch information
alex-courtis authored Sep 1, 2024
1 parent 43c3c36 commit ea55ef1
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 290 deletions.
6 changes: 3 additions & 3 deletions lua/nvim-tree/actions/finders/find-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local log = require "nvim-tree.log"
local view = require "nvim-tree.view"
local utils = require "nvim-tree.utils"
local renderer = require "nvim-tree.renderer"
local reload = require "nvim-tree.explorer.reload"
local core = require "nvim-tree.core"
local Iterator = require "nvim-tree.iterators.node-iterator"

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

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

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

local line = core.get_nodes_starting_line()
Expand Down
11 changes: 6 additions & 5 deletions lua/nvim-tree/actions/reloaders.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
local git = require "nvim-tree.git"
local view = require "nvim-tree.view"
local renderer = require "nvim-tree.renderer"
local explorer_module = require "nvim-tree.explorer"
local core = require "nvim-tree.core"
local explorer_node = require "nvim-tree.explorer.node"
local Iterator = require "nvim-tree.iterators.node-iterator"

local M = {}

---@param node Explorer|nil
---@param explorer Explorer|nil
---@param projects table
local function refresh_nodes(node, projects)
Iterator.builder({ node })
local function refresh_nodes(explorer, projects)
Iterator.builder({ explorer })
:applier(function(n)
if n.nodes then
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path)
explorer_module.reload(n, projects[toplevel] or {})
if explorer then
explorer:reload(n, projects[toplevel] or {})
end
end
end)
:recursor(function(n)
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function M.init(foldername)
if TreeExplorer then
TreeExplorer:destroy()
end
TreeExplorer = explorer.Explorer.new(foldername)
TreeExplorer = explorer:new(foldername)
if not first_init_done then
events._dispatch_ready()
first_init_done = true
Expand Down
Loading

0 comments on commit ea55ef1

Please sign in to comment.