@@ -527,7 +527,7 @@ function Explorer:get_node_at_cursor()
527527 return self
528528 end
529529
530- return utils . get_nodes_by_line (self . nodes , core .get_nodes_starting_line ())[cursor [1 ]]
530+ return self : get_nodes_by_line (core .get_nodes_starting_line ())[cursor [1 ]]
531531end
532532
533533function Explorer :place_cursor_on_node ()
@@ -560,7 +560,7 @@ function Explorer:find_node_line(node)
560560 end
561561
562562 local first_node_line = core .get_nodes_starting_line ()
563- local nodes_by_line = utils . get_nodes_by_line (self . nodes , first_node_line )
563+ local nodes_by_line = self : get_nodes_by_line (first_node_line )
564564 local iter_start , iter_end = first_node_line , # nodes_by_line
565565
566566 for line = iter_start , iter_end , 1 do
@@ -646,6 +646,29 @@ function Explorer:find_node(fn)
646646 return node , i
647647end
648648
649+ --- Return visible nodes indexed by line
650+ --- @param line_start number
651+ --- @return table
652+ function Explorer :get_nodes_by_line (line_start )
653+ local nodes_by_line = {}
654+ local line = line_start
655+
656+ Iterator .builder (self .nodes )
657+ :applier (function (node )
658+ if node .group_next then
659+ return
660+ end
661+ nodes_by_line [line ] = node
662+ line = line + 1
663+ end )
664+ :recursor (function (node )
665+ return node .group_next and { node .group_next } or (node .open and # node .nodes > 0 and node .nodes )
666+ end )
667+ :iterate ()
668+
669+ return nodes_by_line
670+ end
671+
649672--- Api.tree.get_nodes
650673--- @return nvim_tree.api.Node
651674function Explorer :get_nodes ()
0 commit comments