Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cursorless-talon/src/spoken_forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"trailing": "trailing",
"content": "keepContentFilter",
"empty": "keepEmptyFilter",
"expand": "expandToFullLine",
"its": "inferPreviousMark",
"visible": "visible"
},
Expand Down
22 changes: 22 additions & 0 deletions data/fixtures/recorded/modifiers/changeExpand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
languageId: plaintext
command:
version: 7
spokenForm: change expand
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- {type: expandToFullLine}
usePrePhraseSnapshot: false
initialState:
documentContents: " foo "
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ export interface TrailingModifier {
type: "trailing";
}

export interface ExpandToFullLineModifier {
type: "expandToFullLine";
}

export interface KeepContentFilterModifier {
type: "keepContentFilter";
}
Expand Down Expand Up @@ -482,6 +486,7 @@ export type Modifier =
| LeadingModifier
| TrailingModifier
| RawSelectionModifier
| ExpandToFullLineModifier
| ModifyIfUntypedModifier
| FallbackModifier
| RangeModifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ClassFunctionNameStage } from "./modifiers/ClassFunctionNameStage";
import { ModifyIfUntypedStage } from "./modifiers/ConditionalModifierStages";
import { ContainingScopeStage } from "./modifiers/ContainingScopeStage";
import { EveryScopeStage } from "./modifiers/EveryScopeStage";
import { ExpandToFullLineStage } from "./modifiers/ExpandToFullLineStage";
import { FallbackStage } from "./modifiers/FallbackStage";
import {
KeepContentFilterStage,
Expand Down Expand Up @@ -57,6 +58,8 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
return new LeadingStage(this, modifier);
case "trailing":
return new TrailingStage(this, modifier);
case "expandToFullLine":
return new ExpandToFullLineStage(modifier);
case "visible":
return new VisibleStage(modifier);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { ExpandToFullLineModifier } from "@cursorless/common";
import type { Target } from "../../typings/target.types";
import { expandToFullLine } from "../../util/rangeUtils";
import type { ModifierStage } from "../PipelineStages.types";
import { LineTarget } from "../targets";

export class ExpandToFullLineStage implements ModifierStage {
constructor(private modifier: ExpandToFullLineModifier) {}

run(target: Target): Target[] {
const contentRange = expandToFullLine(target.editor, target.contentRange);
return [
new LineTarget({
editor: target.editor,
contentRange,
isReversed: target.isReversed,
}),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
toRawSelection: "just",
leading: "leading",
trailing: "trailing",
expandToFullLine: "expand",
keepContentFilter: "content",
keepEmptyFilter: "empty",
inferPreviousMark: "its",
Expand Down
1 change: 1 addition & 0 deletions packages/cursorless-engine/src/util/getScopeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function getScopeType(modifier: Modifier): ScopeType | undefined {
case "endOf":
case "extendThroughStartOf":
case "extendThroughEndOf":
case "expandToFullLine":
case "fallback":
case "range":
case "modifyIfUntyped":
Expand Down
Loading