Skip to content

Fix Typescript text-based surrounding pairs #355

@pokey

Description

@pokey

In the latest version of the tree-sitter parser, strings contain string fragments, so the existing stringMatcher won't detect them as strings, and thus won't use the text-based parser. Thus, the following will fail

"(hello)"

If we say "take round harp". We need to be a bit more liberal in https://github.com/pokey/cursorless-vscode/blob/0c394d787e3dc88b7f6e629b86789fe76deaf93f/src/processTargets/modifiers/surroundingPair/index.ts#L71

I'm not sure we want to look at all ancestors, or potentially even parents, because they we might avoid parse tree when we're in an interpolation scope within a template string, (eg `foo ${(bar)}`)

We might need to allow languages to define a isInStringFragment function that will default to just using the string matcher, but in typescript will also add string_fragment type

Try running Cursorless unit tests with cursorless-dev/vscode-parse-tree#12 installed to see the failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions