Skip to content

Commit

Permalink
fix(query): iterate over captures for the shortest size, not longest
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq authored and ObserverOfTime committed Oct 24, 2024
1 parent 8b36044 commit 78d558f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tree_sitter/binding/query_predicates.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static inline bool satisfies_eq_capture(ModuleState *state, QueryPredicateEqCapt
PyObject *text1, *text2;
size_t size1 = (size_t)PyList_Size(nodes1), size2 = (size_t)PyList_Size(nodes2);
int result = 1;
for (size_t i = 0, l = size1 > size2 ? size1 : size2; i < l; ++i) {
for (size_t i = 0, l = size1 < size2 ? size1 : size2; i < l; ++i) {
text1 = node_get_text((Node *)PyList_GetItem(nodes1, i), NULL);
text2 = node_get_text((Node *)PyList_GetItem(nodes2, i), NULL);
result = PREDICATE_CMP(text1, text2, predicate);
Expand Down

0 comments on commit 78d558f

Please sign in to comment.