diff --git a/src/Types.ts b/src/Types.ts index 027942a2d..22bcc30a7 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -101,13 +101,21 @@ export interface MatchingPairSymbolModifier { export interface IdentityModifier { type: "identity"; } +export interface HeadModifier { + type: "head"; +} +export interface TailModifier { + type: "tail"; +} export type Modifier = | SurroundingPairModifier | ContainingScopeModifier | SubpieceModifier | MatchingPairSymbolModifier - | IdentityModifier; + | IdentityModifier + | HeadModifier + | TailModifier; export type SelectionType = | "character" diff --git a/src/processTargets.ts b/src/processTargets.ts index 9d5237a61..48cf57662 100644 --- a/src/processTargets.ts +++ b/src/processTargets.ts @@ -348,6 +348,28 @@ function transformSelection( }, }, ]; + + case "head": + case "tail": { + let anchor: Position, active: Position; + if (modifier.type === "head") { + anchor = selection.selection.end; + active = new Position(selection.selection.start.line, 0); + } else { + anchor = selection.selection.start; + active = selection.editor.document.lineAt(selection.selection.end).range + .end; + } + return [ + { + selection: update(selection, { + selection: () => new Selection(anchor, active), + }), + context: {}, + }, + ]; + } + case "matchingPairSymbol": case "surroundingPair": throw new Error("Not implemented");