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

move expand_or_collapse to DirectoryNode
This commit is contained in:
Alexander Courtis
2024-10-14 10:50:22 +11:00
parent 893957a8d9
commit 03f9dd29c4
4 changed files with 40 additions and 33 deletions

View File

@@ -4,6 +4,8 @@ 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")
local M = {}
local MAX_DEPTH = 100
@@ -70,8 +72,10 @@ local function move(where, what, skip_gitignored)
end
end
---@param node Node
local function expand_node(node)
if not node.open then
if node:is(DirectoryNode) and not node.open then
---@cast node DirectoryNode
-- Expand the node.
-- Should never collapse since we checked open.
node:expand_or_collapse()
@@ -96,7 +100,8 @@ local function move_next_recursive(what, skip_gitignored)
if node_init.name ~= ".." then -- root node cannot have a status
valid = status_is_valid(node_init, what, skip_gitignored)
end
if node_init.nodes ~= nil and valid and not node_init.open then
if node_init:is(DirectoryNode) and valid and not node_init.open then
---@cast node_init DirectoryNode
node_init:expand_or_collapse()
end