Fix handling of queries with field names at the roots of patterns

Fixes #1018
This commit is contained in:
Max Brunsfeld 2021-03-27 09:36:13 -07:00
parent 6e8b5e7643
commit 72143b17ff
2 changed files with 21 additions and 2 deletions

View file

@ -2756,8 +2756,9 @@ static inline bool ts_query_cursor__advance(
do {
// If this node matches the first step of the pattern, then add a new
// state at the start of this pattern.
if (step->field && field_id != step->field) continue;
ts_query_cursor__add_state(self, pattern);
if (!step->field || field_id == step->field) {
ts_query_cursor__add_state(self, pattern);
}
// Advance to the next pattern whose root node matches this node.
i++;