Skip to content

Commit 1d2d9d1

Browse files
committed
Revert "chore: resolve undefined-field"
This reverts commit be546ff.
1 parent 8dda8d0 commit 1d2d9d1

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

lua/nvim-tree/utils.lua

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
local Iterator = require("nvim-tree.iterators.node-iterator")
22
local notify = require("nvim-tree.notify")
33

4-
local DirectoryNode = require("nvim-tree.node.directory")
5-
64
local M = {
75
debouncers = {},
86
}
@@ -126,12 +124,7 @@ function M.find_node(nodes, fn)
126124
local node, i = Iterator.builder(nodes)
127125
:matcher(fn)
128126
:recursor(function(node)
129-
local dir = node:as(DirectoryNode)
130-
if dir then
131-
return dir.group_next and { dir.group_next } or (dir.open and #dir.nodes > 0 and dir.nodes)
132-
else
133-
return false
134-
end
127+
return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
135128
end)
136129
:iterate()
137130
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)
186179
return node.absolute_path == path or node.link_to == path
187180
end)
188181
:recursor(function(node)
189-
local dir = node:as(DirectoryNode)
190-
if dir and dir.group_next then
191-
return { dir.group_next }
182+
if node.group_next then
183+
return { node.group_next }
192184
end
193-
if dir then
194-
return dir.nodes
185+
if node.nodes then
186+
return node.nodes
195187
end
196188
end)
197189
:iterate()
@@ -227,20 +219,14 @@ function M.get_nodes_by_line(nodes_all, line_start)
227219

228220
Iterator.builder(nodes_all)
229221
:applier(function(node)
230-
local dir = node:as(DirectoryNode)
231-
if dir and dir.group_next then
222+
if node.group_next then
232223
return
233224
end
234225
nodes_by_line[line] = node
235226
line = line + 1
236227
end)
237228
:recursor(function(node)
238-
local dir = node:as(DirectoryNode)
239-
if dir then
240-
return dir.group_next and { dir.group_next } or (dir.open and #dir.nodes > 0 and dir.nodes)
241-
else
242-
return false
243-
end
229+
return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
244230
end)
245231
:iterate()
246232

0 commit comments

Comments
 (0)