1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:37:35 +00:00

LibCpp: Modify logic of Parser::index_of_node_at

After this commit, Parser::index_of_node_at will prefer to return nodes
with greater indices.

Since the parsing logic ensures that child nodes come after parent
nodes, this change makes this function return child nodes when possible.
This commit is contained in:
Itamar 2021-05-09 21:40:27 +03:00 committed by Andreas Kling
parent f9b8e9c01c
commit 84e41c4565
3 changed files with 6 additions and 2 deletions

View file

@ -899,7 +899,7 @@ Optional<size_t> Parser::index_of_node_at(Position pos) const
if (node.start() > pos || node.end() < pos)
continue;
if (!match_node_index.has_value() || (node_span(node) < node_span(m_state.nodes[match_node_index.value()])))
if (!match_node_index.has_value() || (node_span(node) <= node_span(m_state.nodes[match_node_index.value()])))
match_node_index = node_index;
}
return match_node_index;