cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

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

Open wolfmanstout opened this issue 1 year ago • 0 comments

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.]*)

wolfmanstout avatar Jun 24 '24 04:06 wolfmanstout