Revert "refactor(#2871, #2886): multi instance: node classes created (#2916)"

This reverts commit 38aac09151.
This commit is contained in:
Alexander Courtis
2024-10-08 18:07:47 +11:00
parent 010ae0365a
commit 50e919426a
43 changed files with 742 additions and 835 deletions

View File

@@ -217,10 +217,10 @@ end
---@param action ACTION
---@param action_fn fun(source: string, dest: string)
function Clipboard:do_paste(node, action, action_fn)
if node.name == ".." then
node = self.explorer
else
node = node:last_group_node()
node = lib.get_last_group_node(node)
local explorer = core.get_explorer()
if node.name == ".." and explorer then
node = explorer
end
local clip = self.data[action]
if #clip == 0 then

View File

@@ -1,5 +1,6 @@
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local lib = require("nvim-tree.lib")
local core = require("nvim-tree.core")
local notify = require("nvim-tree.notify")
@@ -39,13 +40,14 @@ local function get_containing_folder(node)
return node.absolute_path:sub(0, -node_name_size - 1)
end
---@param node Node?
---@param node Node|nil
function M.fn(node)
local cwd = core.get_cwd()
if cwd == nil then
return
end
node = node and lib.get_last_group_node(node)
if not node or node.name == ".." then
node = {
absolute_path = cwd,
@@ -53,8 +55,6 @@ function M.fn(node)
nodes = core.get_explorer().nodes,
open = true,
}
else
node = node:last_group_node()
end
local containing_folder = get_containing_folder(node)

View File

@@ -120,7 +120,7 @@ function M.fn(default_modifier)
return
end
node = node:last_group_node()
node = lib.get_last_group_node(node)
if node.name == ".." then
return
end

View File

@@ -2,6 +2,7 @@ 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 explorer_node = require("nvim-tree.explorer.node")
local diagnostics = require("nvim-tree.diagnostics")
local M = {}
@@ -15,7 +16,7 @@ local MAX_DEPTH = 100
---@return boolean
local function status_is_valid(node, what, skip_gitignored)
if what == "git" then
local git_status = node:get_git_status()
local git_status = explorer_node.get_git_status(node)
return git_status ~= nil and (not skip_gitignored or git_status[1] ~= "!!")
elseif what == "diag" then
local diag_status = diagnostics.get_diag_status(node)
@@ -74,7 +75,7 @@ local function expand_node(node)
if not node.open then
-- Expand the node.
-- Should never collapse since we checked open.
node:expand_or_collapse()
lib.expand_or_collapse(node)
end
end
@@ -97,7 +98,7 @@ local function move_next_recursive(what, skip_gitignored)
valid = status_is_valid(node_init, what, skip_gitignored)
end
if node_init.nodes ~= nil and valid and not node_init.open then
node_init:expand_or_collapse()
lib.expand_or_collapse(node_init)
end
move("next", what, skip_gitignored)

View File

@@ -1,6 +1,7 @@
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local core = require("nvim-tree.core")
local lib = require("nvim-tree.lib")
local M = {}
@@ -11,7 +12,7 @@ function M.fn(should_close)
return function(node)
local explorer = core.get_explorer()
node = node:last_group_node()
node = lib.get_last_group_node(node)
if should_close and node.open then
node.open = false
if explorer then
@@ -20,7 +21,7 @@ function M.fn(should_close)
return
end
local parent = node:get_parent_of_group().parent
local parent = utils.get_parent_of_group(node).parent
if not parent or not parent.parent then
return view.set_cursor({ 1, 0 })

View File

@@ -15,7 +15,7 @@ function M.fn(direction)
local first, last, next, prev = nil, nil, nil, nil
local found = false
local parent = node.parent or core.get_explorer()
Iterator.builder(parent and parent.nodes or {})
Iterator.builder(parent.nodes)
:recursor(function()
return nil
end)

View File

@@ -1,6 +1,7 @@
local core = require("nvim-tree.core")
local Iterator = require("nvim-tree.iterators.node-iterator")
local notify = require("nvim-tree.notify")
local lib = require("nvim-tree.lib")
local M = {}
@@ -17,7 +18,7 @@ end
---@param node Node
local function expand(node)
node = node:last_group_node()
node = lib.get_last_group_node(node)
node.open = true
if #node.nodes == 0 then
core.get_explorer():expand(node)
@@ -61,10 +62,10 @@ local function gen_iterator()
end
end
---@param node Node
function M.fn(node)
---@param base_node table
function M.fn(base_node)
local explorer = core.get_explorer()
node = node.nodes and node or explorer
local node = base_node.nodes and base_node or explorer
if gen_iterator()(node) then
notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders")
end