Skip to content

refactor(#2837): multi instance reload #2885

New issue

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

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

Already on GitHub? # to your account

Merged
merged 3 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
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
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
Loading