refactor(#2941): move lib methods to explorer (#2964)

* add todo

* refactor(#2886): multi instance: node class refactoring: extract links, *_git_status (#2944)

* extract DirectoryLinkNode and FileLinkNode, move Node methods to children

* temporarily move DirectoryNode methods into BaseNode for easier reviewing

* move mostly unchanged DirectoryNode methods back to BaseNode

* tidy

* git.git_status_file takes an array

* update git status of links

* luacheck hack

* safer git_status_dir

* refactor(#2886): multi instance: node class refactoring: DirectoryNode:expand_or_collapse (#2957)

move expand_or_collapse to DirectoryNode

* refactor(#2886): multi instance: node group functions refactoring (#2959)

* move last_group_node to DirectoryNode

* move add BaseNode:as and more doc

* revert parameter name changes

* revert parameter name changes

* add Class

* move group methods into DN

* tidy group methods

* tidy group methods

* tidy group methods

* tidy group methods

* parent is DirectoryNode

* tidy expand all

* BaseNode -> Node

* move watcher to DirectoryNode

* last_group_node is DirectoryNode only

* simplify create-file

* simplify parent

* simplify collapse-all

* simplify live-filter

* style

* move lib.get_cursor_position to Explorer

* move lib.get_node_at_cursor to Explorer

* move lib.get_nodes to Explorer

* move place_cursor_on_node to Explorer

* resolve resource leak in purge_all_state

* move many autocommands into Explorer

* post merge tidy
This commit is contained in:
Alexander Courtis
2024-10-27 09:03:26 +11:00
committed by GitHub
parent 8760d76c1d
commit f3efc25e56
15 changed files with 257 additions and 244 deletions

View File

@@ -1,6 +1,4 @@
local lib = require("nvim-tree.lib")
local log = require("nvim-tree.log")
local appearance = require("nvim-tree.appearance")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local actions = require("nvim-tree.actions")
@@ -115,27 +113,6 @@ function M.open_on_directory()
actions.root.change_dir.force_dirchange(bufname, true)
end
function M.place_cursor_on_node()
local ok, search = pcall(vim.fn.searchcount)
if ok and search and search.exact_match == 1 then
return
end
local node = lib.get_node_at_cursor()
if not node or node.name == ".." then
return
end
node = node:get_parent_of_group() or node
local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0)
local idx = vim.fn.stridx(line, node.name)
if idx >= 0 then
vim.api.nvim_win_set_cursor(0, { cursor[1], idx })
end
end
---@return table
function M.get_config()
return M.config
@@ -173,19 +150,6 @@ local function setup_autocommands(opts)
vim.api.nvim_create_autocmd(name, vim.tbl_extend("force", default_opts, custom_opts))
end
-- reset and draw (highlights) when colorscheme is changed
create_nvim_tree_autocmd("ColorScheme", {
callback = function()
appearance.setup()
view.reset_winhl()
local explorer = core.get_explorer()
if explorer then
explorer.renderer:draw()
end
end,
})
-- prevent new opened file from opening in the same window as nvim-tree
create_nvim_tree_autocmd("BufWipeout", {
pattern = "NvimTree_*",
@@ -201,76 +165,9 @@ local function setup_autocommands(opts)
end,
})
create_nvim_tree_autocmd("BufWritePost", {
callback = function()
if opts.auto_reload_on_write and not opts.filesystem_watchers.enable then
local explorer = core.get_explorer()
if explorer then
explorer:reload_explorer()
end
end
end,
})
create_nvim_tree_autocmd("BufReadPost", {
callback = function(data)
-- update opened file buffers
local explorer = core.get_explorer()
if not explorer then
return
end
if
(explorer.filters.config.filter_no_buffer or explorer.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == ""
then
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
explorer:reload_explorer()
end)
end
end,
})
create_nvim_tree_autocmd("BufUnload", {
callback = function(data)
-- update opened file buffers
local explorer = core.get_explorer()
if not explorer then
return
end
if
(explorer.filters.config.filter_no_buffer or explorer.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == ""
then
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
explorer:reload_explorer()
end)
end
end,
})
create_nvim_tree_autocmd("User", {
pattern = { "FugitiveChanged", "NeogitStatusRefreshed" },
callback = function()
if not opts.filesystem_watchers.enable and opts.git.enable then
local explorer = core.get_explorer()
if explorer then
explorer:reload_git()
end
end
end,
})
if opts.tab.sync.open then
create_nvim_tree_autocmd("TabEnter", { callback = vim.schedule_wrap(M.tab_enter) })
end
if opts.hijack_cursor then
create_nvim_tree_autocmd("CursorMoved", {
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
M.place_cursor_on_node()
end
end,
})
end
if opts.sync_root_with_cwd then
create_nvim_tree_autocmd("DirChanged", {
callback = function()
@@ -296,20 +193,6 @@ local function setup_autocommands(opts)
create_nvim_tree_autocmd({ "BufEnter", "BufNewFile" }, { callback = M.open_on_directory })
end
create_nvim_tree_autocmd("BufEnter", {
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
if vim.fn.getcwd() ~= core.get_cwd() or (opts.reload_on_bufenter and not opts.filesystem_watchers.enable) then
local explorer = core.get_explorer()
if explorer then
explorer:reload_explorer()
end
end
end
end,
})
if opts.view.centralize_selection then
create_nvim_tree_autocmd("BufEnter", {
pattern = "NvimTree_*",
@@ -349,20 +232,6 @@ local function setup_autocommands(opts)
end,
})
end
if opts.modified.enable then
create_nvim_tree_autocmd({ "BufModifiedSet", "BufWritePost" }, {
callback = function()
utils.debounce("Buf:modified", opts.view.debounce_delay, function()
require("nvim-tree.buffers").reload_modified()
local explorer = core.get_explorer()
if explorer then
explorer:reload_explorer()
end
end)
end,
})
end
end
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
@@ -805,13 +674,16 @@ local function localise_default_opts()
end
function M.purge_all_state()
require("nvim-tree.watcher").purge_watchers()
view.close_all_tabs()
view.abandon_all_windows()
if core.get_explorer() ~= nil then
local explorer = core.get_explorer()
if explorer then
require("nvim-tree.git").purge_state()
explorer:destroy()
core.reset_explorer()
end
-- purge orphaned that were not destroyed by their nodes
require("nvim-tree.watcher").purge_watchers()
end
---@param conf table|nil
@@ -855,6 +727,7 @@ function M.setup(conf)
require("nvim-tree.appearance").setup()
require("nvim-tree.diagnostics").setup(opts)
require("nvim-tree.explorer"):setup(opts)
require("nvim-tree.explorer.watch").setup(opts)
require("nvim-tree.git").setup(opts)
require("nvim-tree.git.utils").setup(opts)
require("nvim-tree.view").setup(opts)

View File

@@ -1,5 +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")
local notify = require("nvim-tree.notify")
@@ -104,11 +103,15 @@ function M.fn(default_modifier)
default_modifier = default_modifier or ":t"
return function(node, modifier)
if type(node) ~= "table" then
node = lib.get_node_at_cursor()
local explorer = core.get_explorer()
if not explorer then
return
end
if node == nil then
if type(node) ~= "table" then
node = explorer:get_node_at_cursor()
end
if not node then
return
end
@@ -160,11 +163,8 @@ function M.fn(default_modifier)
M.rename(node, prepend .. new_file_path .. append)
if not M.config.filesystem_watchers.enable then
local explorer = core.get_explorer()
if explorer then
explorer:reload_explorer()
end
end
find_file(utils.path_remove_trailing(new_file_path))
end)

View File

@@ -1,7 +1,6 @@
local utils = require("nvim-tree.utils")
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local lib = require("nvim-tree.lib")
local diagnostics = require("nvim-tree.diagnostics")
local DirectoryNode = require("nvim-tree.node.directory")
@@ -30,15 +29,16 @@ local function status_is_valid(node, what, skip_gitignored)
end
---Move to the next node that has a valid status. If none found, don't move.
---@param explorer Explorer
---@param where string where to move (forwards or backwards)
---@param what string type of status
---@param skip_gitignored boolean default false
local function move(where, what, skip_gitignored)
local function move(explorer, where, what, skip_gitignored)
local first_node_line = core.get_nodes_starting_line()
local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, first_node_line)
local nodes_by_line = utils.get_nodes_by_line(explorer.nodes, first_node_line)
local iter_start, iter_end, iter_step, cur, first, nex
local cursor = lib.get_cursor_position()
local cursor = explorer:get_cursor_position()
if cursor and cursor[1] < first_node_line then
cur = cursor[1]
end
@@ -82,16 +82,17 @@ local function expand_node(node)
end
--- Move to the next node recursively.
---@param explorer Explorer
---@param what string type of status
---@param skip_gitignored boolean default false
local function move_next_recursive(what, skip_gitignored)
local function move_next_recursive(explorer, what, skip_gitignored)
-- If the current node:
-- * is a directory
-- * and is not the root node
-- * and has a git/diag status
-- * and is not opened
-- expand it.
local node_init = lib.get_node_at_cursor()
local node_init = explorer:get_node_at_cursor()
if not node_init then
return
end
@@ -104,9 +105,9 @@ local function move_next_recursive(what, skip_gitignored)
node_dir:expand_or_collapse(false)
end
move("next", what, skip_gitignored)
move(explorer, "next", what, skip_gitignored)
local node_cur = lib.get_node_at_cursor()
local node_cur = explorer:get_node_at_cursor()
if not node_cur then
return
end
@@ -122,10 +123,10 @@ local function move_next_recursive(what, skip_gitignored)
while dir_cur and i < MAX_DEPTH do
expand_node(dir_cur)
move("next", what, skip_gitignored)
move(explorer, "next", what, skip_gitignored)
-- Save current node.
node_cur = lib.get_node_at_cursor()
node_cur = explorer:get_node_at_cursor()
dir_cur = node_cur and node_cur:as(DirectoryNode)
i = i + 1
@@ -147,24 +148,25 @@ end
--- 4.4) Call a non-recursive prev.
--- 4.5) Save the current node and start back from 4.1.
---
---@param explorer Explorer
---@param what string type of status
---@param skip_gitignored boolean default false
local function move_prev_recursive(what, skip_gitignored)
local function move_prev_recursive(explorer, what, skip_gitignored)
local node_init, node_cur
-- 1)
node_init = lib.get_node_at_cursor()
node_init = explorer:get_node_at_cursor()
if node_init == nil then
return
end
-- 2)
move("prev", what, skip_gitignored)
move(explorer, "prev", what, skip_gitignored)
node_cur = lib.get_node_at_cursor()
node_cur = explorer:get_node_at_cursor()
if node_cur == node_init.parent then
-- 3)
move_prev_recursive(what, skip_gitignored)
move_prev_recursive(explorer, what, skip_gitignored)
else
-- i is used to limit iterations.
local i = 0
@@ -196,10 +198,10 @@ local function move_prev_recursive(what, skip_gitignored)
end
-- 4.4)
move("prev", what, skip_gitignored)
move(explorer, "prev", what, skip_gitignored)
-- 4.5)
node_cur = lib.get_node_at_cursor()
node_cur = explorer:get_node_at_cursor()
i = i + 1
end
@@ -214,6 +216,11 @@ end
---@return fun()
function M.fn(opts)
return function()
local explorer = core.get_explorer()
if not explorer then
return
end
local recurse = false
local skip_gitignored = false
@@ -227,14 +234,14 @@ function M.fn(opts)
end
if not recurse then
move(opts.where, opts.what, skip_gitignored)
move(explorer, opts.where, opts.what, skip_gitignored)
return
end
if opts.where == "next" then
move_next_recursive(opts.what, skip_gitignored)
move_next_recursive(explorer, opts.what, skip_gitignored)
elseif opts.where == "prev" then
move_prev_recursive(opts.what, skip_gitignored)
move_prev_recursive(explorer, opts.what, skip_gitignored)
end
end
end

View File

@@ -1,6 +1,5 @@
local utils = require("nvim-tree.utils")
local core = require("nvim-tree.core")
local lib = require("nvim-tree.lib")
local Iterator = require("nvim-tree.iterators.node-iterator")
local DirectoryNode = require("nvim-tree.node.directory")
@@ -26,10 +25,13 @@ end
---@param keep_buffers boolean
function M.fn(keep_buffers)
local node = lib.get_node_at_cursor()
local explorer = core.get_explorer()
if not explorer then
return
end
if explorer == nil then
local node = explorer:get_node_at_cursor()
if not node then
return
end

View File

@@ -1,14 +1,15 @@
local lib = require("nvim-tree.lib")
local utils = require("nvim-tree.utils")
local core = require("nvim-tree.core")
local M = {}
---@param explorer Explorer
local function reload(explorer)
local node = lib.get_node_at_cursor()
local node = explorer:get_node_at_cursor()
explorer:reload_explorer()
if node then
utils.focus_node_or_parent(node)
end
end
local function wrap_explorer(fn)
return function(...)

View File

@@ -1,4 +1,3 @@
local lib = require("nvim-tree.lib")
local core = require("nvim-tree.core")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
@@ -54,28 +53,6 @@ local function wrap(fn)
end
end
---Inject the node as the first argument if present otherwise do nothing.
---@param fn fun(node: Node, ...): any
---@return fun(node: Node, ...): any
local function wrap_node(fn)
return function(node, ...)
node = node or lib.get_node_at_cursor()
if node then
return fn(node, ...)
end
end
end
---Inject the node or nil as the first argument if absent.
---@param fn fun(node: Node, ...): any
---@return fun(node: Node, ...): any
local function wrap_node_or_nil(fn)
return function(node, ...)
node = node or lib.get_node_at_cursor()
return fn(node, ...)
end
end
---Invoke a method on the singleton explorer.
---Print error when setup not called.
---@param explorer_method string explorer method name
@@ -89,6 +66,28 @@ local function wrap_explorer(explorer_method)
end)
end
---Inject the node as the first argument if present otherwise do nothing.
---@param fn fun(node: Node, ...): any
---@return fun(node: Node, ...): any
local function wrap_node(fn)
return function(node, ...)
node = node or wrap_explorer("get_node_at_cursor")()
if node then
return fn(node, ...)
end
end
end
---Inject the node or nil as the first argument if absent.
---@param fn fun(node: Node, ...): any
---@return fun(node: Node, ...): any
local function wrap_node_or_nil(fn)
return function(node, ...)
node = node or wrap_explorer("get_node_at_cursor")()
return fn(node, ...)
end
end
---Invoke a member's method on the singleton explorer.
---Print error when setup not called.
---@param explorer_member string explorer member name
@@ -147,8 +146,8 @@ Api.tree.change_root_to_node = wrap_node(function(node)
end)
Api.tree.change_root_to_parent = wrap_node(actions.root.dir_up.fn)
Api.tree.get_node_under_cursor = wrap(lib.get_node_at_cursor)
Api.tree.get_nodes = wrap(lib.get_nodes)
Api.tree.get_node_under_cursor = wrap_explorer("get_node_at_cursor")
Api.tree.get_nodes = wrap_explorer("get_nodes")
---@class ApiTreeFindFileOpts
---@field buf string|number|nil

View File

@@ -1,3 +1,6 @@
local appearance = require("nvim-tree.appearance")
local buffers = require("nvim-tree.buffers")
local core = require("nvim-tree.core")
local git = require("nvim-tree.git")
local log = require("nvim-tree.log")
local notify = require("nvim-tree.notify")
@@ -24,7 +27,9 @@ local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
local config
---@class (exact) Explorer: RootNode
---@field uid_explorer number vim.uv.hrtime() at construction time
---@field opts table user options
---@field augroup_id integer
---@field renderer Renderer
---@field filters Filters
---@field live_filter LiveFilter
@@ -58,6 +63,9 @@ function Explorer:create(path)
o.explorer = o
o.uid_explorer = vim.uv.hrtime()
o.augroup_id = vim.api.nvim_create_augroup("NvimTree_Explorer_" .. o.uid_explorer, {})
o.open = true
o.opts = config
@@ -68,11 +76,111 @@ function Explorer:create(path)
o.marks = Marks:new(config, o)
o.clipboard = Clipboard:new(config, o)
o:create_autocmds()
o:_load(o)
return o
end
function Explorer:destroy()
log.line("dev", "Explorer:destroy")
vim.api.nvim_del_augroup_by_id(self.augroup_id)
RootNode.destroy(self)
end
function Explorer:create_autocmds()
-- reset and draw (highlights) when colorscheme is changed
vim.api.nvim_create_autocmd("ColorScheme", {
group = self.augroup_id,
callback = function()
appearance.setup()
view.reset_winhl()
self:draw()
end,
})
vim.api.nvim_create_autocmd("BufWritePost", {
group = self.augroup_id,
callback = function()
if self.opts.auto_reload_on_write and not self.opts.filesystem_watchers.enable then
self:reload_explorer()
end
end,
})
vim.api.nvim_create_autocmd("BufReadPost", {
group = self.augroup_id,
callback = function(data)
if (self.filters.config.filter_no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
self:reload_explorer()
end)
end
end,
})
-- update opened file buffers
vim.api.nvim_create_autocmd("BufUnload", {
group = self.augroup_id,
callback = function(data)
if (self.filters.config.filter_no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
self:reload_explorer()
end)
end
end,
})
vim.api.nvim_create_autocmd("BufEnter", {
group = self.augroup_id,
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
if vim.fn.getcwd() ~= core.get_cwd() or (self.opts.reload_on_bufenter and not self.opts.filesystem_watchers.enable) then
self:reload_explorer()
end
end
end,
})
vim.api.nvim_create_autocmd("User", {
group = self.augroup_id,
pattern = { "FugitiveChanged", "NeogitStatusRefreshed" },
callback = function()
if not self.opts.filesystem_watchers.enable and self.opts.git.enable then
self:reload_git()
end
end,
})
if self.opts.hijack_cursor then
vim.api.nvim_create_autocmd("CursorMoved", {
group = self.augroup_id,
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
self:place_cursor_on_node()
end
end,
})
end
if self.opts.modified.enable then
vim.api.nvim_create_autocmd({ "BufModifiedSet", "BufWritePost" }, {
group = self.augroup_id,
callback = function()
utils.debounce("Buf:modified_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
buffers.reload_modified()
self:reload_explorer()
end)
end,
})
end
end
---@param node DirectoryNode
function Explorer:expand(node)
self:_load(node)
@@ -375,9 +483,61 @@ function Explorer:reload_git()
event_running = false
end
---Cursor position as per vim.api.nvim_win_get_cursor
---nil on no explorer or invalid view win
---@return integer[]|nil
function Explorer:get_cursor_position()
local winnr = view.get_winnr()
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
return
end
return vim.api.nvim_win_get_cursor(winnr)
end
---@return Node|nil
function Explorer:get_node_at_cursor()
local cursor = self:get_cursor_position()
if not cursor then
return
end
if cursor[1] == 1 and view.is_root_folder_visible(core.get_cwd()) then
return self
end
return utils.get_nodes_by_line(self.nodes, core.get_nodes_starting_line())[cursor[1]]
end
function Explorer:place_cursor_on_node()
local ok, search = pcall(vim.fn.searchcount)
if ok and search and search.exact_match == 1 then
return
end
local node = self:get_node_at_cursor()
if not node or node.name == ".." then
return
end
node = node:get_parent_of_group() or node
local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0)
local idx = vim.fn.stridx(line, node.name)
if idx >= 0 then
vim.api.nvim_win_set_cursor(0, { cursor[1], idx })
end
end
---Api.tree.get_nodes
---@return Node
function Explorer:get_nodes()
return self:clone()
end
function Explorer:setup(opts)
config = opts
require("nvim-tree.explorer.watch").setup(opts)
end
return Explorer

View File

@@ -197,7 +197,7 @@ local function create_overlay(self)
end
function LiveFilter:start_filtering()
view.View.live_filter.prev_focused_node = require("nvim-tree.lib").get_node_at_cursor()
view.View.live_filter.prev_focused_node = self.explorer:get_node_at_cursor()
self.filter = self.filter or ""
self.explorer.renderer:draw()
@@ -211,7 +211,7 @@ function LiveFilter:start_filtering()
end
function LiveFilter:clear_filter()
local node = require("nvim-tree.lib").get_node_at_cursor()
local node = self.explorer:get_node_at_cursor()
local last_node = view.View.live_filter.prev_focused_node
self.filter = nil

View File

@@ -1,6 +1,5 @@
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local notify = require("nvim-tree.notify")
@@ -13,48 +12,6 @@ local M = {
target_winid = nil,
}
---Cursor position as per vim.api.nvim_win_get_cursor
---nil on no explorer or invalid view win
---@return integer[]|nil
function M.get_cursor_position()
if not core.get_explorer() then
return
end
local winnr = view.get_winnr()
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
return
end
return vim.api.nvim_win_get_cursor(winnr)
end
---@return Node|nil
function M.get_node_at_cursor()
local explorer = core.get_explorer()
if not explorer then
return
end
local cursor = M.get_cursor_position()
if not cursor then
return
end
if cursor[1] == 1 and view.is_root_folder_visible(core.get_cwd()) then
return explorer
end
return utils.get_nodes_by_line(explorer.nodes, core.get_nodes_starting_line())[cursor[1]]
end
---Api.tree.get_nodes
---@return Node[]?
function M.get_nodes()
local explorer = core.get_explorer()
return explorer and explorer:clone()
end
function M.set_target_win()
local id = vim.api.nvim_get_current_win()
local tree_id = view.get_winnr()

View File

@@ -88,14 +88,12 @@ function M.set_inspect_opts(opts)
end
--- Write to log file the inspection of a node
--- defaults to the node under cursor if none is provided
---@param typ string as per log.types config
---@param node Node? node to be inspected
---@param node Node node to be inspected
---@param fmt string for string.format
---@param ... any arguments for string.format
function M.node(typ, node, fmt, ...)
if M.enabled(typ) then
node = node or require("nvim-tree.lib").get_node_at_cursor()
M.raw(typ, string.format("[%s] [%s] %s\n%s\n", os.date("%Y-%m-%d %H:%M:%S"), typ, (fmt or "???"), vim.inspect(node, inspect_opts)), ...)
end
end

View File

@@ -151,7 +151,7 @@ function Marks:bulk_move()
return
end
local node_at_cursor = lib.get_node_at_cursor()
local node_at_cursor = self.explorer:get_node_at_cursor()
local default_path = core.get_cwd()
if node_at_cursor and node_at_cursor:is(DirectoryNode) then
@@ -190,7 +190,7 @@ end
---@private
---@param up boolean
function Marks:navigate(up)
local node = lib.get_node_at_cursor()
local node = self.explorer:get_node_at_cursor()
if not node then
return
end

View File

@@ -32,6 +32,10 @@ function DirectoryLinkNode:create(explorer, parent, absolute_path, link_to, name
return o
end
function DirectoryLinkNode:destroy()
DirectoryNode.destroy(self)
end
-----Update the directory GitStatus of link target and the file status of the link itself
-----@param parent_ignored boolean
-----@param status table|nil

View File

@@ -28,6 +28,10 @@ function FileLinkNode:create(explorer, parent, absolute_path, link_to, name, fs_
return o
end
function FileLinkNode:destroy()
FileNode.destroy(self)
end
-----Update the GitStatus of the target otherwise the link itself
-----@param parent_ignored boolean
-----@param status table|nil

View File

@@ -36,6 +36,10 @@ function FileNode:create(explorer, parent, absolute_path, name, fs_stat)
return o
end
function FileNode:destroy()
Node.destroy(self)
end
---Update the GitStatus of the file
---@param parent_ignored boolean
---@param status table|nil

View File

@@ -23,4 +23,8 @@ function RootNode:is_dotfile()
return false
end
function RootNode:destroy()
DirectoryNode.destroy(self)
end
return RootNode