cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.09k stars 77 forks source link

Unable to use "@" in string literals within .scm files #2447

Open wolfmanstout opened 1 week ago

wolfmanstout commented 1 week ago

I bumped into this while working on Kotlin support. Here is what triggered it:

(jump_expression
  "return@"
  .
  (label)
  .
  (_) @value
) @_.domain

This triggers an "invalid capture" error within Cursorless. The problematic code is here: https://github.com/cursorless-dev/cursorless/blob/4eca0350da10c2052930aa5c6eb2e09faee0e949/packages/cursorless-engine/src/languages/TreeSitterQuery/validateQueryCaptures.ts#L61-L86

ChatGPT suggests the following regex to fix this, which looks like it might actually work: ^(?!;;)(?:[^'"]|"[^"]*"|'[^']*')*?@([\\w.]*)