refactor(#2882, #2883): multi instance explore, reloaders (#2897)

* refactor(#2883): multi instance explore

* refactor(#2882): multi instance reloaders

* style
This commit is contained in:
Alexander Courtis
2024-09-14 15:35:31 +10:00
committed by GitHub
parent 03f737e574
commit cd9c6db77f
12 changed files with 247 additions and 115 deletions

View File

@@ -5,7 +5,6 @@ local core = require "nvim-tree.core"
local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify"
local renderer = require "nvim-tree.renderer"
local reloaders = require "nvim-tree.actions.reloaders"
local find_file = require("nvim-tree.actions.finders.find-file").fn
@@ -248,7 +247,7 @@ function Clipboard:do_paste(node, action, action_fn)
self.data[action] = {}
if not self.config.filesystem_watchers.enable then
reloaders.reload_explorer()
self.explorer:reload_explorer()
end
end

View File

@@ -1,3 +1,4 @@
local core = require "nvim-tree.core"
local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events"
local view = require "nvim-tree.view"
@@ -116,8 +117,9 @@ function M.fn(node)
local function do_remove()
M.remove(node)
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders").reload_explorer()
local explorer = core.get_explorer()
if not M.config.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end

View File

@@ -1,3 +1,4 @@
local core = require "nvim-tree.core"
local lib = require "nvim-tree.lib"
local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events"
@@ -155,7 +156,10 @@ function M.fn(default_modifier)
M.rename(node, prepend .. new_file_path .. append)
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders").reload_explorer()
local explorer = core.get_explorer()
if explorer then
explorer:reload_explorer()
end
end
find_file(utils.path_remove_trailing(new_file_path))

View File

@@ -1,6 +1,6 @@
local core = require "nvim-tree.core"
local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify"
local reloaders = require "nvim-tree.actions.reloaders"
local M = {
config = {},
@@ -52,6 +52,8 @@ function M.remove(node)
end
end
local explorer = core.get_explorer()
if node.nodes ~= nil and not node.link_to then
trash_path(function(_, rc)
if rc ~= 0 then
@@ -59,8 +61,8 @@ function M.remove(node)
return
end
events._dispatch_folder_removed(node.absolute_path)
if not M.config.filesystem_watchers.enable then
reloaders.reload_explorer()
if not M.config.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end)
else
@@ -72,8 +74,8 @@ function M.remove(node)
end
events._dispatch_file_removed(node.absolute_path)
clear_buffer(node.absolute_path)
if not M.config.filesystem_watchers.enable then
reloaders.reload_explorer()
if not M.config.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end)
end