From 6db1575feebef7a70a8c09ccb199c28d9c3c79d8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 17 Jan 2025 14:49:04 +0100 Subject: [PATCH] Disqualify arrow delimiter in function type (#2731) Disqualified `=>` in typescript function type definitions to be used in a matching pair delimiter. ## Checklist - [x] 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 --- .../languages/typescript/changeInside.yml | 22 +++++++++++++++++++ .../typescript.core/disqualifyDelimiter.scope | 5 +++++ .../scopeSupportFacets.types.ts | 1 - .../src/scopeSupportFacets/typescript.ts | 2 ++ queries/typescript.core.scm | 5 +++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/recorded/languages/typescript/changeInside.yml create mode 100644 data/fixtures/scopes/typescript.core/disqualifyDelimiter.scope diff --git a/data/fixtures/recorded/languages/typescript/changeInside.yml b/data/fixtures/recorded/languages/typescript/changeInside.yml new file mode 100644 index 0000000000..453a1b5dd8 --- /dev/null +++ b/data/fixtures/recorded/languages/typescript/changeInside.yml @@ -0,0 +1,22 @@ +languageId: typescript +command: + version: 7 + spokenForm: change inside + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + usePrePhraseSnapshot: false +initialState: + documentContents: Promise<() => number>; + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} + marks: {} +finalState: + documentContents: Promise<>; + selections: + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} diff --git a/data/fixtures/scopes/typescript.core/disqualifyDelimiter.scope b/data/fixtures/scopes/typescript.core/disqualifyDelimiter.scope new file mode 100644 index 0000000000..8d72ab1b8d --- /dev/null +++ b/data/fixtures/scopes/typescript.core/disqualifyDelimiter.scope @@ -0,0 +1,5 @@ +Promise<() => number> +--- +[Content] = 0:11-0:13 + >--< +0| Promise<() => number> diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 14fbdc19cf..7983aa9384 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -171,7 +171,6 @@ export const scopeSupportFacets = [ // FIXME: Still in legacy // selector // unit - // collectionItem ] as const; export interface ScopeSupportFacetInfo { diff --git a/packages/common/src/scopeSupportFacets/typescript.ts b/packages/common/src/scopeSupportFacets/typescript.ts index a5e8521164..ee1a64e127 100644 --- a/packages/common/src/scopeSupportFacets/typescript.ts +++ b/packages/common/src/scopeSupportFacets/typescript.ts @@ -24,4 +24,6 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { "value.field": supported, "value.typeAlias": supported, + + disqualifyDelimiter: supported, }; diff --git a/queries/typescript.core.scm b/queries/typescript.core.scm index fc2023685b..88e2871e86 100644 --- a/queries/typescript.core.scm +++ b/queries/typescript.core.scm @@ -382,3 +382,8 @@ . ";"? @statement.end ) + +;; () => number +(function_type + "=>" @disqualifyDelimiter +)