* refactor(#2837): multi instance reload * refactor(#2837): multi instance reload
This commit is contained in:
committed by
GitHub
parent
43c3c36c7a
commit
ea55ef1203
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user