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

@@ -112,8 +112,7 @@ function M.find_node(nodes, fn)
end)
:iterate()
i = require("nvim-tree.view").is_root_folder_visible() and i or i - 1
local explorer = require("nvim-tree.core").get_explorer()
if explorer and explorer.live_filter.filter then
if node and node.explorer.live_filter.filter then
i = i + 1
end
return node, i
@@ -121,7 +120,7 @@ end
-- Find the line number of a node.
-- Return -1 is node is nil or not found.
---@param node Node|nil
---@param node Node?
---@return integer
function M.find_node_line(node)
if not node then
@@ -174,16 +173,6 @@ function M.get_node_from_path(path)
:iterate()
end
---Get the highest parent of grouped nodes
---@param node Node
---@return Node node or parent
function M.get_parent_of_group(node)
while node and node.parent and node.parent.group_next do
node = node.parent
end
return node
end
M.default_format_hidden_count = function(hidden_count, simple)
local parts = {}
local total_count = 0
@@ -473,7 +462,7 @@ end
---Focus node passed as parameter if visible, otherwise focus first visible parent.
---If none of the parents is visible focus root.
---If node is nil do nothing.
---@param node Node|nil node to focus
---@param node Node? node to focus
function M.focus_node_or_parent(node)
local explorer = require("nvim-tree.core").get_explorer()
@@ -549,14 +538,6 @@ function M.array_remove_nils(array)
end, array)
end
---@param f fun(node: Node|nil)
---@return function
function M.inject_node(f)
return function()
f(require("nvim-tree.lib").get_node_at_cursor())
end
end
--- Is the buffer named NvimTree_[0-9]+ a tree? filetype is "NvimTree" or not readable file.
--- This is cheap, as the readable test should only ever be needed when resuming a vim session.
---@param bufnr number|nil may be 0 or nil for current
@@ -578,4 +559,16 @@ function M.is_nvim_tree_buf(bufnr)
return false
end
--- path is an executable file or directory
---@param absolute_path string
---@return boolean
function M.is_executable(absolute_path)
if M.is_windows or M.is_wsl then
--- executable detection on windows is buggy and not performant hence it is disabled
return false
else
return vim.loop.fs_access(absolute_path, "X") or false
end
end
return M