mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-05 05:17:38 +03:00
Added modifiers head and tail (#159)
* Added modifiers head and tail * Include selection
This commit is contained in:
parent
8462eba875
commit
34c4ea88ba
10
src/Types.ts
10
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"
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user