|
1 | 1 | local Iterator = require("nvim-tree.iterators.node-iterator")
|
2 | 2 | local notify = require("nvim-tree.notify")
|
3 | 3 |
|
4 |
| -local DirectoryNode = require("nvim-tree.node.directory") |
5 |
| - |
6 | 4 | local M = {
|
7 | 5 | debouncers = {},
|
8 | 6 | }
|
@@ -126,12 +124,7 @@ function M.find_node(nodes, fn)
|
126 | 124 | local node, i = Iterator.builder(nodes)
|
127 | 125 | :matcher(fn)
|
128 | 126 | :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) |
135 | 128 | end)
|
136 | 129 | :iterate()
|
137 | 130 | 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)
|
186 | 179 | return node.absolute_path == path or node.link_to == path
|
187 | 180 | end)
|
188 | 181 | :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 } |
192 | 184 | end
|
193 |
| - if dir then |
194 |
| - return dir.nodes |
| 185 | + if node.nodes then |
| 186 | + return node.nodes |
195 | 187 | end
|
196 | 188 | end)
|
197 | 189 | :iterate()
|
@@ -227,20 +219,14 @@ function M.get_nodes_by_line(nodes_all, line_start)
|
227 | 219 |
|
228 | 220 | Iterator.builder(nodes_all)
|
229 | 221 | :applier(function(node)
|
230 |
| - local dir = node:as(DirectoryNode) |
231 |
| - if dir and dir.group_next then |
| 222 | + if node.group_next then |
232 | 223 | return
|
233 | 224 | end
|
234 | 225 | nodes_by_line[line] = node
|
235 | 226 | line = line + 1
|
236 | 227 | end)
|
237 | 228 | :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) |
244 | 230 | end)
|
245 | 231 | :iterate()
|
246 | 232 |
|
|
0 commit comments