fix(#2945): stack overflow on api.git.reload or fugitive event with watchers disabled (#2949)

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

This reverts commit 50e919426a.

* fix(#2945): stack overflow on api.git.reload or fugitive event
This commit is contained in:
Alexander Courtis
2024-10-11 13:47:01 +11:00
committed by GitHub
parent 50e919426a
commit 5ad87620ec
43 changed files with 835 additions and 742 deletions

View File

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

View File

@@ -1,7 +1,6 @@
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 = {}
@@ -12,7 +11,7 @@ function M.fn(should_close)
return function(node)
local explorer = core.get_explorer()
node = lib.get_last_group_node(node)
node = node:last_group_node()
if should_close and node.open then
node.open = false
if explorer then
@@ -21,7 +20,7 @@ function M.fn(should_close)
return
end
local parent = utils.get_parent_of_group(node).parent
local parent = node:get_parent_of_group().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.nodes)
Iterator.builder(parent and parent.nodes or {})
:recursor(function()
return nil
end)