Revert "chore: resolve undefined-field"

This reverts commit be546ff18d41f28466b065c857e1e041659bd2c8.
This commit is contained in:
Alexander Courtis
2024-10-25 18:17:47 +11:00
parent e9e4bcdd18
commit 4ba0db7ec9

View File

@@ -1,8 +1,6 @@
local Iterator = require("nvim-tree.iterators.node-iterator") local Iterator = require("nvim-tree.iterators.node-iterator")
local notify = require("nvim-tree.notify") local notify = require("nvim-tree.notify")
local DirectoryNode = require("nvim-tree.node.directory")
local M = { local M = {
debouncers = {}, debouncers = {},
} }
@@ -126,12 +124,7 @@ function M.find_node(nodes, fn)
local node, i = Iterator.builder(nodes) local node, i = Iterator.builder(nodes)
:matcher(fn) :matcher(fn)
:recursor(function(node) :recursor(function(node)
local dir = node:as(DirectoryNode) return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
if dir then
return dir.group_next and { dir.group_next } or (dir.open and #dir.nodes > 0 and dir.nodes)
else
return false
end
end) end)
:iterate() :iterate()
i = require("nvim-tree.view").is_root_folder_visible() and i or i - 1 i = require("nvim-tree.view").is_root_folder_visible() and i or i - 1
@@ -186,12 +179,11 @@ function M.get_node_from_path(path)
return node.absolute_path == path or node.link_to == path return node.absolute_path == path or node.link_to == path
end) end)
:recursor(function(node) :recursor(function(node)
local dir = node:as(DirectoryNode) if node.group_next then
if dir and dir.group_next then return { node.group_next }
return { dir.group_next }
end end
if dir then if node.nodes then
return dir.nodes return node.nodes
end end
end) end)
:iterate() :iterate()
@@ -227,20 +219,14 @@ function M.get_nodes_by_line(nodes_all, line_start)
Iterator.builder(nodes_all) Iterator.builder(nodes_all)
:applier(function(node) :applier(function(node)
local dir = node:as(DirectoryNode) if node.group_next then
if dir and dir.group_next then
return return
end end
nodes_by_line[line] = node nodes_by_line[line] = node
line = line + 1 line = line + 1
end) end)
:recursor(function(node) :recursor(function(node)
local dir = node:as(DirectoryNode) return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
if dir then
return dir.group_next and { dir.group_next } or (dir.open and #dir.nodes > 0 and dir.nodes)
else
return false
end
end) end)
:iterate() :iterate()