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,23 +1,24 @@
local HL_POSITION = require("nvim-tree.enum").HL_POSITION
local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT
local explorer_node = require("nvim-tree.explorer.node")
local Decorator = require("nvim-tree.renderer.decorator")
---@class (exact) DecoratorHidden: Decorator
---@field icon HighlightedString|nil
---@field icon HighlightedString?
local DecoratorHidden = Decorator:new()
---Static factory method
---@param opts table
---@param explorer Explorer
---@return DecoratorHidden
function DecoratorHidden:new(opts, explorer)
local o = Decorator.new(self, {
function DecoratorHidden:create(opts, explorer)
---@type DecoratorHidden
local o = {
explorer = explorer,
enabled = true,
hl_pos = HL_POSITION[opts.renderer.highlight_hidden] or HL_POSITION.none,
icon_placement = ICON_PLACEMENT[opts.renderer.icons.hidden_placement] or ICON_PLACEMENT.none,
})
---@cast o DecoratorHidden
}
o = self:new(o) --[[@as DecoratorHidden]]
if opts.renderer.icons.show.hidden then
o.icon = {
@@ -34,7 +35,7 @@ end
---@param node Node
---@return HighlightedString[]|nil icons
function DecoratorHidden:calculate_icons(node)
if self.enabled and explorer_node.is_dotfile(node) then
if self.enabled and node:is_dotfile() then
return { self.icon }
end
end
@@ -43,7 +44,7 @@ end
---@param node Node
---@return string|nil group
function DecoratorHidden:calculate_highlight(node)
if not self.enabled or self.hl_pos == HL_POSITION.none or (not explorer_node.is_dotfile(node)) then
if not self.enabled or self.hl_pos == HL_POSITION.none or not node:is_dotfile() then
return nil
end