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

@@ -1,6 +1,5 @@
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")
@@ -40,14 +39,13 @@ local function get_containing_folder(node)
return node.absolute_path:sub(0, -node_name_size - 1)
end
---@param node Node|nil
---@param node Node?
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,
@@ -55,6 +53,8 @@ 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)