Skip to content

Commit 29056a7

Browse files
authored
Clean up runCommand (#1486)
## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [x] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet
1 parent 950860e commit 29056a7

File tree

15 files changed

+394
-320
lines changed

15 files changed

+394
-320
lines changed

docs/contributing/_api-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ contributors get up to speed.
77
For the time being, we recommend watching the [internals walk-through
88
videos](https://youtube.com/playlist?list=PLkafpFOBVedScHi0dy_80DsHwnZIOSOTy)
99
and having a look through the API docs, starting from the [`runCommand`
10-
function](classes/cursorless_engine_src_core_commandRunner_CommandRunner.CommandRunner#runcommand).
10+
function](modules/cursorless_engine_src_runCommand).

packages/common/src/types/command/ActionCommand.ts

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
1-
export type ActionType =
2-
| "callAsFunction"
3-
| "clearAndSetSelection"
4-
| "copyToClipboard"
5-
| "cutToClipboard"
6-
| "deselect"
7-
| "editNew"
8-
| "editNewLineAfter"
9-
| "editNewLineBefore"
10-
| "executeCommand"
11-
| "extractVariable"
12-
| "findInWorkspace"
13-
| "foldRegion"
14-
| "followLink"
15-
| "generateSnippet"
16-
| "getText"
17-
| "highlight"
18-
| "indentLine"
19-
| "insertCopyAfter"
20-
| "insertCopyBefore"
21-
| "insertEmptyLineAfter"
22-
| "insertEmptyLineBefore"
23-
| "insertEmptyLinesAround"
24-
| "insertSnippet"
25-
| "moveToTarget"
26-
| "outdentLine"
27-
| "pasteFromClipboard"
28-
| "randomizeTargets"
29-
| "remove"
30-
| "rename"
31-
| "replace"
32-
| "replaceWithTarget"
33-
| "revealDefinition"
34-
| "revealTypeDefinition"
35-
| "reverseTargets"
36-
| "rewrapWithPairedDelimiter"
37-
| "scrollToBottom"
38-
| "scrollToCenter"
39-
| "scrollToTop"
40-
| "setSelection"
41-
| "setSelectionAfter"
42-
| "setSelectionBefore"
43-
| "showDebugHover"
44-
| "showHover"
45-
| "showQuickFix"
46-
| "showReferences"
47-
| "sortTargets"
48-
| "swapTargets"
49-
| "toggleLineBreakpoint"
50-
| "toggleLineComment"
51-
| "unfoldRegion"
52-
| "wrapWithPairedDelimiter"
53-
| "wrapWithSnippet";
1+
export const actionNames = [
2+
"callAsFunction",
3+
"clearAndSetSelection",
4+
"copyToClipboard",
5+
"cutToClipboard",
6+
"deselect",
7+
"editNew",
8+
"editNewLineAfter",
9+
"editNewLineBefore",
10+
"executeCommand",
11+
"extractVariable",
12+
"findInWorkspace",
13+
"foldRegion",
14+
"followLink",
15+
"generateSnippet",
16+
"getText",
17+
"highlight",
18+
"indentLine",
19+
"insertCopyAfter",
20+
"insertCopyBefore",
21+
"insertEmptyLineAfter",
22+
"insertEmptyLineBefore",
23+
"insertEmptyLinesAround",
24+
"insertSnippet",
25+
"moveToTarget",
26+
"outdentLine",
27+
"pasteFromClipboard",
28+
"randomizeTargets",
29+
"remove",
30+
"rename",
31+
"replace",
32+
"replaceWithTarget",
33+
"revealDefinition",
34+
"revealTypeDefinition",
35+
"reverseTargets",
36+
"rewrapWithPairedDelimiter",
37+
"scrollToBottom",
38+
"scrollToCenter",
39+
"scrollToTop",
40+
"setSelection",
41+
"setSelectionAfter",
42+
"setSelectionBefore",
43+
"showDebugHover",
44+
"showHover",
45+
"showQuickFix",
46+
"showReferences",
47+
"sortTargets",
48+
"swapTargets",
49+
"toggleLineBreakpoint",
50+
"toggleLineComment",
51+
"unfoldRegion",
52+
"wrapWithPairedDelimiter",
53+
"wrapWithSnippet",
54+
] as const;
55+
56+
export type ActionType = (typeof actionNames)[number];
5457

5558
export interface ActionCommand {
5659
/**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { CommandComplete } from "@cursorless/common";
2+
3+
export interface CommandRunner {
4+
run(command: CommandComplete): Promise<unknown>;
5+
}

packages/cursorless-engine/src/actions/CallbackAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EditableTextEditor, FlashStyle, TextEditor } from "@cursorless/common";
22
import { flatten } from "lodash";
3-
import { selectionToThatTarget } from "../core/commandRunner/selectionToThatTarget";
3+
import { selectionToStoredTarget } from "../core/commandRunner/selectionToStoredTarget";
44
import { RangeUpdater } from "../core/updateSelections/RangeUpdater";
55
import { callFunctionAndUpdateSelections } from "../core/updateSelections/updateSelections";
66
import { ide } from "../singletons/ide.singleton";
@@ -128,7 +128,7 @@ export class CallbackAction implements Action {
128128
return editor.document.version === originalEditorVersion
129129
? targets
130130
: updatedTargetSelections.map((selection) =>
131-
selectionToThatTarget({
131+
selectionToStoredTarget({
132132
editor,
133133
selection,
134134
}),

packages/cursorless-engine/src/core/commandRunner/CommandRunner.ts

Lines changed: 0 additions & 226 deletions
This file was deleted.

0 commit comments

Comments
 (0)