diff --git a/packages/common/src/ide/types/Configuration.ts b/packages/common/src/ide/types/Configuration.ts index 6ee3a7bc87..6becf59b46 100644 --- a/packages/common/src/ide/types/Configuration.ts +++ b/packages/common/src/ide/types/Configuration.ts @@ -9,6 +9,9 @@ export type CursorlessConfiguration = { experimental: { snippetsDir: string | undefined; hatStability: HatStability }; decorationDebounceDelayMs: number; debug: boolean; + private: { + lineParagraphIterationScope: boolean; + }; }; export type CursorlessConfigKey = keyof CursorlessConfiguration; @@ -27,6 +30,9 @@ 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 d16a0640fb..ac9b8bce0a 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts @@ -1,17 +1,25 @@ -import { Position, Range, TextEditor } from "@cursorless/common"; -import { Direction, ScopeType } from "@cursorless/common"; +import { + Direction, + 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 = { type: "document" } as const; + public readonly iterationScopeType: ScopeType; protected readonly isHierarchical = false; public readonly includeAdjacentInEvery: boolean = true; constructor(_scopeType: ScopeType, _languageId: string) { super(); + this.iterationScopeType = { type: getIterationScopeTypeType() }; } *generateScopeCandidates( @@ -67,3 +75,10 @@ export function fitRangeToLineContent(editor: TextEditor, range: Range) { endLine.lastNonWhitespaceCharacterIndex, ); } + +function getIterationScopeTypeType(): SimpleScopeTypeType { + const useParagraph = ide().configuration.getOwnConfiguration( + "private.lineParagraphIterationScope", + ); + return useParagraph ? "paragraph" : "document"; +}