Skip to content

Commit 2b0a50c

Browse files
authored
Fix is-nth-child predicate (#1533)
## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet
1 parent fcdf70c commit 2b0a50c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IsNthChild extends QueryPredicateOperator<IsNthChild> {
4242
name = "is-nth-child?" as const;
4343
schema = z.tuple([q.node, q.integer]);
4444
run({ node }: MutableQueryCapture, n: number) {
45-
return node.parent?.children.indexOf(node) === n;
45+
return node.parent?.children.findIndex((n) => n.id === node.id) === n;
4646
}
4747
}
4848

0 commit comments

Comments
 (0)