Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/io/github/treesitter/jtreesitter/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ private void handlePredicates(String source, MemorySegment query, @Unsigned int
if ((steps = count.get(C_INT, 0)) == 0) continue;
int offset = ts_query_start_byte_for_pattern(query, i);
long row = source.chars().limit(offset).filter(c -> c == '\n').count();
for (long j = 0, nargs = 0; j < steps; ++j) {
for (long j = 0; j < steps;) {
long nargs = 0;
for (; ; ++nargs) {
var t = TSQueryPredicateStep.asSlice(tokens, nargs);
if (TSQueryPredicateStep.type(t) == TSQueryPredicateStepTypeDone()) break;
Expand Down Expand Up @@ -266,8 +267,8 @@ private void handlePredicates(String source, MemorySegment query, @Unsigned int
}
predicates.get(i).add(new QueryPredicate(predicate, values));
}
j += nargs;
tokens = TSQueryPredicateStep.asSlice(tokens, nargs);
j += nargs + 1;
tokens = TSQueryPredicateStep.asSlice(tokens, nargs + 1);
}
}
}
Expand Down