Skip to content

Commit

Permalink
Added modifiers head and tail (#159)
Browse files Browse the repository at this point in the history
* Added modifiers head and tail

* Include selection
  • Loading branch information
AndreasArvidsson authored Aug 1, 2021
1 parent 7425b05 commit df20a98
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions src/processTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit df20a98

Please sign in to comment.