Added modifiers head and tail (#159)

* Added modifiers head and tail

* Include selection
This commit is contained in:
Andreas Arvidsson 2021-08-01 14:15:50 +02:00 committed by Pokey Rule
parent 8462eba875
commit 34c4ea88ba
2 changed files with 31 additions and 1 deletions

View File

@ -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"

View File

@ -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");