From a4ab8da6af0f3ea6a33cd3ecdfd5a2e25e33862e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 5 Dec 2023 12:31:19 +0100 Subject: [PATCH] Make paragraph line iteration scope (#2060) ## 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 --------- Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> --- .../common/src/ide/types/Configuration.ts | 6 --- .../scopeHandlers/LineScopeHandler.ts | 14 ++----- .../recorded/everyScope/changeEveryLine.yml | 39 +++++++++++++++++++ .../modifiers/everyScope/clearEveryLine.yml | 4 +- .../recorded/selectionTypes/takeEveryLine.yml | 4 +- 5 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/everyScope/changeEveryLine.yml diff --git a/packages/common/src/ide/types/Configuration.ts b/packages/common/src/ide/types/Configuration.ts index 6becf59b46..6ee3a7bc87 100644 --- a/packages/common/src/ide/types/Configuration.ts +++ b/packages/common/src/ide/types/Configuration.ts @@ -9,9 +9,6 @@ export type CursorlessConfiguration = { experimental: { snippetsDir: string | undefined; hatStability: HatStability }; decorationDebounceDelayMs: number; debug: boolean; - private: { - lineParagraphIterationScope: boolean; - }; }; export type CursorlessConfigKey = keyof CursorlessConfiguration; @@ -30,9 +27,6 @@ export const CONFIGURATION_DEFAULTS: CursorlessConfiguration = { hatStability: HatStability.balanced, }, debug: false, - private: { - lineParagraphIterationScope: false, - }, }; export interface Configuration { diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts index ac9b8bce0a..e57b1094c5 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts @@ -3,23 +3,22 @@ import { Position, Range, ScopeType, - SimpleScopeTypeType, TextEditor, } from "@cursorless/common"; -import { ide } from "../../../singletons/ide.singleton"; import { LineTarget } from "../../targets"; import { BaseScopeHandler } from "./BaseScopeHandler"; import type { TargetScope } from "./scope.types"; export class LineScopeHandler extends BaseScopeHandler { public readonly scopeType = { type: "line" } as const; - public readonly iterationScopeType: ScopeType; + public readonly iterationScopeType: ScopeType = { + type: "paragraph", + } as const; protected readonly isHierarchical = false; public readonly includeAdjacentInEvery: boolean = true; constructor(_scopeType: ScopeType, _languageId: string) { super(); - this.iterationScopeType = { type: getIterationScopeTypeType() }; } *generateScopeCandidates( @@ -75,10 +74,3 @@ export function fitRangeToLineContent(editor: TextEditor, range: Range) { endLine.lastNonWhitespaceCharacterIndex, ); } - -function getIterationScopeTypeType(): SimpleScopeTypeType { - const useParagraph = ide().configuration.getOwnConfiguration( - "private.lineParagraphIterationScope", - ); - return useParagraph ? "paragraph" : "document"; -} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/everyScope/changeEveryLine.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/everyScope/changeEveryLine.yml new file mode 100644 index 0000000000..306d46f435 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/everyScope/changeEveryLine.yml @@ -0,0 +1,39 @@ +languageId: plaintext +command: + version: 6 + spokenForm: change every line + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: everyScope + scopeType: {type: line} + usePrePhraseSnapshot: true +initialState: + documentContents: | + + a + + b c + d e + f g + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + marks: {} +finalState: + documentContents: |+ + + a + + + + + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + - anchor: {line: 4, character: 0} + active: {line: 4, character: 0} + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/modifiers/everyScope/clearEveryLine.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/modifiers/everyScope/clearEveryLine.yml index c19c71f88b..59902feb8a 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/modifiers/everyScope/clearEveryLine.yml +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/modifiers/everyScope/clearEveryLine.yml @@ -1,12 +1,14 @@ languageId: plaintext command: - spokenForm: change every line + spokenForm: change every line file version: 3 targets: - type: primitive modifiers: - type: everyScope scopeType: {type: line} + - type: containingScope + scopeType: {type: document} usePrePhraseSnapshot: true action: {name: clearAndSetSelection} initialState: diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/selectionTypes/takeEveryLine.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/selectionTypes/takeEveryLine.yml index 21870b59c2..bf845d386f 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/selectionTypes/takeEveryLine.yml +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/selectionTypes/takeEveryLine.yml @@ -1,6 +1,6 @@ languageId: plaintext command: - spokenForm: take every line + spokenForm: take every line file version: 2 action: {name: setSelection} targets: @@ -8,6 +8,8 @@ command: modifiers: - type: everyScope scopeType: {type: line} + - type: containingScope + scopeType: {type: document} usePrePhraseSnapshot: true initialState: documentContents: |