diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 1d4e56c7e8..79832ddeb2 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -12,6 +12,9 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.foreach": supported, "type.foreach": supported, + "comment.line": supported, + "comment.block": supported, + element: notApplicable, tags: notApplicable, attribute: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 4c6d25572e..26198da4be 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -16,6 +16,9 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal": supportedLegacy, "argument.formal.iteration": supportedLegacy, + "comment.line": supported, + "comment.block": supported, + element: notApplicable, tags: notApplicable, attribute: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index b9cff24296..e4aae83ca6 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -9,4 +9,7 @@ const { supported } = ScopeSupportFacetLevel; export const talonScopeSupport: LanguageScopeSupportFacetMap = { command: supported, + + "comment.line": supported, + "comment.block": supported, }; diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block.scope new file mode 100644 index 0000000000..c6263b704d --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block.scope @@ -0,0 +1,16 @@ +/* + Hello world +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:2 +0| /* + >-- +1| Hello world + ------------- +2| */ + --< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block2.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block2.scope new file mode 100644 index 0000000000..0b1fc29e6e --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block2.scope @@ -0,0 +1,16 @@ +/** +* Hello world +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:2 +0| /** + >--- +1| * Hello world + ------------- +2| */ + --< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block3.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block3.scope new file mode 100644 index 0000000000..4e43c0ebd8 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.block3.scope @@ -0,0 +1,13 @@ +// Hello +// World +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:8 +0| // Hello + >-------- +1| // World + --------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.line.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.line.scope new file mode 100644 index 0000000000..517cc2e6e2 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 +0| // Hello world + >--------------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/comment.block3.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/comment.block3.scope new file mode 100644 index 0000000000..4e43c0ebd8 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/comment.block3.scope @@ -0,0 +1,13 @@ +// Hello +// World +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:8 +0| // Hello + >-------- +1| // World + --------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.block.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.block.scope new file mode 100644 index 0000000000..2763f25c13 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.block.scope @@ -0,0 +1,13 @@ +# Hello +# World +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:7 +0| # Hello + >------- +1| # World + -------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.line.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.line.scope new file mode 100644 index 0000000000..94396062e4 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 +0| # Hello world + >-------------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.block.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.block.scope new file mode 100644 index 0000000000..2763f25c13 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.block.scope @@ -0,0 +1,13 @@ +# Hello +# World +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:7 +0| # Hello + >------- +1| # World + -------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.line.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.line.scope new file mode 100644 index 0000000000..94396062e4 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/talon/comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 +0| # Hello world + >-------------< + +[Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts b/packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts index c53ba5d837..6527a7deb1 100644 --- a/packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts +++ b/packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts @@ -145,19 +145,17 @@ function getScopeType( scopeType: ScopeType; isIteration: boolean; } { - if (languageId === "textual") { - const { scopeType, isIteration } = - textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet]; - return { - scopeType: { type: scopeType }, - isIteration: isIteration ?? false, - }; + const facetInfo = + languageId === "textual" + ? textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet] + : scopeSupportFacetInfos[facetId as ScopeSupportFacet]; + + if (facetInfo == null) { + throw Error(`Unknown facet '${facetId}'`); } - const { scopeType, isIteration } = - scopeSupportFacetInfos[facetId as ScopeSupportFacet]; return { - scopeType: { type: scopeType }, - isIteration: isIteration ?? false, + scopeType: { type: facetInfo.scopeType }, + isIteration: facetInfo.isIteration ?? false, }; } diff --git a/queries/talon.scm b/queries/talon.scm index 884e7b94ff..ce796296c7 100644 --- a/queries/talon.scm +++ b/queries/talon.scm @@ -174,4 +174,7 @@ arguments: (_) @argumentOrParameter.iteration ;;!! # foo ;;! ^^^^^ -(comment) @comment +( + (comment) @comment + (#contiguous! @comment) +)