Skip to content

Commit 99cf030

Browse files
authored
improve treesitter query captureStartEnd error messages (#1887)
These used to print things like "[Object object]". They are interface types, so we can't simply add a toString method. ## 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 2b1bf99 commit 99cf030

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export function checkCaptureStartEnd(
6060
showError(
6161
messages,
6262
"TreeSitterQuery.checkCaptures.mixRegularStartEnd",
63-
`Please do not mix regular captures and start/end captures: ${captures}`,
63+
`Please do not mix regular captures and start/end captures: ${captures.map(
64+
({ name, range }) => name + " " + range.toString(),
65+
)}`,
6466
);
6567
shownError = true;
6668
}
@@ -71,7 +73,7 @@ export function checkCaptureStartEnd(
7173
messages,
7274
"TreeSitterQuery.checkCaptures.duplicate",
7375
`A capture with the same name may only appear once in a single pattern: ${captures.map(
74-
({ name }) => name,
76+
({ name, range }) => name + " " + range.toString(),
7577
)}`,
7678
);
7779
shownError = true;

0 commit comments

Comments
 (0)