Skip to content

Commit d981813

Browse files
Added private setting to change line iteration scope to paragraph (#2022)
`"cursorless.private.lineParagraphIterationScope": true,` ## Checklist - [-] 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
1 parent 56b8431 commit d981813

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

packages/common/src/ide/types/Configuration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export type CursorlessConfiguration = {
99
experimental: { snippetsDir: string | undefined; hatStability: HatStability };
1010
decorationDebounceDelayMs: number;
1111
debug: boolean;
12+
private: {
13+
lineParagraphIterationScope: boolean;
14+
};
1215
};
1316

1417
export type CursorlessConfigKey = keyof CursorlessConfiguration;
@@ -27,6 +30,9 @@ export const CONFIGURATION_DEFAULTS: CursorlessConfiguration = {
2730
hatStability: HatStability.balanced,
2831
},
2932
debug: false,
33+
private: {
34+
lineParagraphIterationScope: false,
35+
},
3036
};
3137

3238
export interface Configuration {

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/LineScopeHandler.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import { Position, Range, TextEditor } from "@cursorless/common";
2-
import { Direction, ScopeType } from "@cursorless/common";
1+
import {
2+
Direction,
3+
Position,
4+
Range,
5+
ScopeType,
6+
SimpleScopeTypeType,
7+
TextEditor,
8+
} from "@cursorless/common";
9+
import { ide } from "../../../singletons/ide.singleton";
310
import { LineTarget } from "../../targets";
411
import { BaseScopeHandler } from "./BaseScopeHandler";
512
import type { TargetScope } from "./scope.types";
613

714
export class LineScopeHandler extends BaseScopeHandler {
815
public readonly scopeType = { type: "line" } as const;
9-
public readonly iterationScopeType = { type: "document" } as const;
16+
public readonly iterationScopeType: ScopeType;
1017
protected readonly isHierarchical = false;
1118
public readonly includeAdjacentInEvery: boolean = true;
1219

1320
constructor(_scopeType: ScopeType, _languageId: string) {
1421
super();
22+
this.iterationScopeType = { type: getIterationScopeTypeType() };
1523
}
1624

1725
*generateScopeCandidates(
@@ -67,3 +75,10 @@ export function fitRangeToLineContent(editor: TextEditor, range: Range) {
6775
endLine.lastNonWhitespaceCharacterIndex,
6876
);
6977
}
78+
79+
function getIterationScopeTypeType(): SimpleScopeTypeType {
80+
const useParagraph = ide().configuration.getOwnConfiguration(
81+
"private.lineParagraphIterationScope",
82+
);
83+
return useParagraph ? "paragraph" : "document";
84+
}

0 commit comments

Comments
 (0)