-
-
Notifications
You must be signed in to change notification settings - Fork 88
Destinations as first-class objects #1605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
107 commits
Select commit
Hold shift + click to select a range
03761b2
Started working on destination migration
AndreasArvidsson 397a80c
stuff
AndreasArvidsson 5793b28
more work
AndreasArvidsson 09be83f
Test passes
AndreasArvidsson 40e5301
Is not a token
AndreasArvidsson e370a28
Merge branch 'main' into destination
AndreasArvidsson 4803508
Add destination during command version upgrade dependent on action name
AndreasArvidsson 38b85ed
cleanup
AndreasArvidsson e52df85
Removed position target and implemented destination
AndreasArvidsson 3c6bb5d
cleanup
AndreasArvidsson 170c2cc
Merge branch 'main' into destination
AndreasArvidsson 6c530de
Added new action types
AndreasArvidsson a42ab5c
cleanup
AndreasArvidsson a9215ef
clean up validation
AndreasArvidsson a855bec
stuff
AndreasArvidsson b09d599
Merge branch 'main' into destination
AndreasArvidsson c0b72e5
tidy tidy
AndreasArvidsson 558baf7
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] e8cbd25
stuff
AndreasArvidsson 5dc4ff0
Merge branches 'destination' and 'destination' of github.com:cursorle…
AndreasArvidsson 8881b0f
Merge branch 'main' into destination
AndreasArvidsson 648a12c
stuff2
AndreasArvidsson 3800c91
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 42fa23a
clean
AndreasArvidsson 65c2b52
Merge branch 'destination' of github.com:cursorless-dev/cursorless in…
AndreasArvidsson a414407
Rough draft of inference on destinations
pokey dbbae33
bring move swap is working
AndreasArvidsson e6877db
update
AndreasArvidsson 04206de
Started migrating actions
AndreasArvidsson 6d18160
more changes
AndreasArvidsson 9fffc11
bug fixes
AndreasArvidsson cf85117
stuff
AndreasArvidsson 4f55a0a
update snippet
AndreasArvidsson 10743c9
fix
AndreasArvidsson c2e1ea3
update
AndreasArvidsson 69ccb77
remove tests
AndreasArvidsson c43be25
stuff
AndreasArvidsson 86d4de4
stuff
AndreasArvidsson 1134171
Added vertical range target
AndreasArvidsson 3f7b40d
stuff
AndreasArvidsson 3b8917b
remove
AndreasArvidsson bbf01f3
blob
AndreasArvidsson ea300bc
Update the test case recorder tests
AndreasArvidsson 5accb88
Updated type destination to primitive destination
AndreasArvidsson 6c95c6d
fix
AndreasArvidsson 2bef7b3
cleanup
AndreasArvidsson 379736a
updated test
AndreasArvidsson 2d3c828
fix
AndreasArvidsson 1fbb31c
fix
AndreasArvidsson 41f25d6
cleanup
AndreasArvidsson b165299
renamed file
AndreasArvidsson 6d6ee1b
jsdocs / renames
pokey c55d1dc
tweak jsdocs
pokey 38c6fa3
cleanup
pokey edd5f2a
inline arguments in `CommandRunnerImpl`
pokey dde3247
Resurrect post-inference debugging
pokey 9c3366a
Update packages/cursorless-engine/src/actions/EditNew/runNotebookCell…
AndreasArvidsson 63b945b
Ked fixed bug
AndreasArvidsson 701d974
Rename
AndreasArvidsson 0c6498b
cleanup
AndreasArvidsson fc6f649
rename
pokey f45aa36
tweak view
pokey 75063ce
remove comment
pokey 5a95c65
always use raw target for position stage
AndreasArvidsson b4043a9
Added implicit destination
AndreasArvidsson 4f9618d
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] fb87903
clean
AndreasArvidsson d9d3514
Merge branch 'destination' of github.com:cursorless-dev/cursorless in…
AndreasArvidsson f9e5628
Cleanup
pokey da816eb
whoops
pokey 94c2ecd
more tweaks
pokey bd02d1b
Removed the word partial from action descriptors
AndreasArvidsson 0f5818c
Remove one more `Partial`
pokey 157b0fd
More cleanup
pokey 31c789f
More simplification
pokey c899a61
more cleanup
pokey 467315e
Improve typing; cleanup `editNew`
pokey 8c886b6
Cleanup typing and make validate avoid mutation
pokey c693062
Js doc
pokey afaff47
Js doc
pokey 8bff62c
Ja stock
pokey 02747e0
move edit new stuff to new file
pokey aef20eb
Continues splitting up bring move swap
pokey d360790
Comments
pokey 41b72e8
Add comments
pokey 416db50
Make upgrade code more closely match Talon
pokey ea7b2fe
more cleanup
pokey b059c7e
cleanup inference comments
pokey 4d252fd
Added type for get text action
AndreasArvidsson e481710
Added get text test
AndreasArvidsson a387d97
Updated get text test
AndreasArvidsson 62c4b95
cleanup
pokey 53ecf4c
cleanup
pokey 5acd577
rename
pokey a9ac2da
cleanup
pokey 794c164
cleanup
pokey eb327e4
cleanup
pokey 5c4debf
cleanup
pokey 822c07b
more
pokey a26aac4
Cleanup
pokey 12044c4
More cleanup
pokey 71d6f56
Remove `VerticalRangeTarget`
pokey 43ee76d
Remove some default imports
pokey c53d1bd
clean up tests
pokey db052bd
whoops
pokey 081d5df
Re-add removed tests
pokey 6a41a7e
Merge branch 'main' into destination
pokey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
import { | ||
PartialTargetDescriptor, | ||
ScopeType, | ||
} from "./PartialTargetDescriptor.types"; | ||
import { DestinationDescriptor } from "./DestinationDescriptor.types"; | ||
|
||
/** | ||
* A simple action takes only a single target and no other arguments. | ||
*/ | ||
const simpleActionNames = [ | ||
"clearAndSetSelection", | ||
"copyToClipboard", | ||
"cutToClipboard", | ||
"deselect", | ||
"editNewLineAfter", | ||
"editNewLineBefore", | ||
"experimental.setInstanceReference", | ||
"extractVariable", | ||
"findInWorkspace", | ||
"foldRegion", | ||
"followLink", | ||
"indentLine", | ||
"insertCopyAfter", | ||
"insertCopyBefore", | ||
"insertEmptyLineAfter", | ||
"insertEmptyLineBefore", | ||
"insertEmptyLinesAround", | ||
"outdentLine", | ||
"randomizeTargets", | ||
"remove", | ||
"rename", | ||
"revealDefinition", | ||
"revealTypeDefinition", | ||
"reverseTargets", | ||
"scrollToBottom", | ||
"scrollToCenter", | ||
"scrollToTop", | ||
"setSelection", | ||
"setSelectionAfter", | ||
"setSelectionBefore", | ||
"showDebugHover", | ||
"showHover", | ||
"showQuickFix", | ||
"showReferences", | ||
"sortTargets", | ||
"toggleLineBreakpoint", | ||
"toggleLineComment", | ||
"unfoldRegion", | ||
] as const; | ||
|
||
const complexActionNames = [ | ||
"callAsFunction", | ||
"editNew", | ||
"executeCommand", | ||
"generateSnippet", | ||
"getText", | ||
"highlight", | ||
"insertSnippet", | ||
"moveToTarget", | ||
"pasteFromClipboard", | ||
"replace", | ||
"replaceWithTarget", | ||
"rewrapWithPairedDelimiter", | ||
"swapTargets", | ||
"wrapWithPairedDelimiter", | ||
"wrapWithSnippet", | ||
] as const; | ||
|
||
export const actionNames = [ | ||
...simpleActionNames, | ||
...complexActionNames, | ||
] as const; | ||
|
||
export type SimpleActionName = (typeof simpleActionNames)[number]; | ||
export type ActionType = (typeof actionNames)[number]; | ||
|
||
/** | ||
* A simple action takes only a single target and no other arguments. | ||
*/ | ||
export interface SimpleActionDescriptor { | ||
name: SimpleActionName; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export interface BringMoveActionDescriptor { | ||
name: "replaceWithTarget" | "moveToTarget"; | ||
source: PartialTargetDescriptor; | ||
destination: DestinationDescriptor; | ||
} | ||
|
||
export interface CallActionDescriptor { | ||
name: "callAsFunction"; | ||
|
||
/** | ||
* The target to use as the function to be called. | ||
*/ | ||
callee: PartialTargetDescriptor; | ||
|
||
/** | ||
* The target to wrap in a function call. | ||
*/ | ||
argument: PartialTargetDescriptor; | ||
} | ||
|
||
export interface SwapActionDescriptor { | ||
name: "swapTargets"; | ||
target1: PartialTargetDescriptor; | ||
target2: PartialTargetDescriptor; | ||
} | ||
|
||
export interface WrapWithPairedDelimiterActionDescriptor { | ||
name: "wrapWithPairedDelimiter" | "rewrapWithPairedDelimiter"; | ||
left: string; | ||
right: string; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export interface PasteActionDescriptor { | ||
name: "pasteFromClipboard"; | ||
destination: DestinationDescriptor; | ||
} | ||
|
||
export interface GenerateSnippetActionDescriptor { | ||
name: "generateSnippet"; | ||
snippetName?: string; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
interface NamedInsertSnippetArg { | ||
type: "named"; | ||
name: string; | ||
substitutions?: Record<string, string>; | ||
} | ||
interface CustomInsertSnippetArg { | ||
type: "custom"; | ||
body: string; | ||
scopeType?: ScopeType; | ||
substitutions?: Record<string, string>; | ||
} | ||
export type InsertSnippetArg = NamedInsertSnippetArg | CustomInsertSnippetArg; | ||
|
||
export interface InsertSnippetActionDescriptor { | ||
name: "insertSnippet"; | ||
snippetDescription: InsertSnippetArg; | ||
destination: DestinationDescriptor; | ||
} | ||
|
||
interface NamedWrapWithSnippetArg { | ||
type: "named"; | ||
name: string; | ||
variableName: string; | ||
} | ||
interface CustomWrapWithSnippetArg { | ||
type: "custom"; | ||
body: string; | ||
variableName?: string; | ||
scopeType?: ScopeType; | ||
} | ||
export type WrapWithSnippetArg = | ||
| NamedWrapWithSnippetArg | ||
| CustomWrapWithSnippetArg; | ||
|
||
export interface WrapWithSnippetActionDescriptor { | ||
name: "wrapWithSnippet"; | ||
snippetDescription: WrapWithSnippetArg; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export interface ExecuteCommandOptions { | ||
commandArgs?: any[]; | ||
ensureSingleEditor?: boolean; | ||
ensureSingleTarget?: boolean; | ||
restoreSelection?: boolean; | ||
showDecorations?: boolean; | ||
} | ||
|
||
export interface ExecuteCommandActionDescriptor { | ||
name: "executeCommand"; | ||
commandId: string; | ||
options?: ExecuteCommandOptions; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export type ReplaceWith = string[] | { start: number }; | ||
|
||
export interface ReplaceActionDescriptor { | ||
name: "replace"; | ||
AndreasArvidsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
replaceWith: ReplaceWith; | ||
destination: DestinationDescriptor; | ||
} | ||
|
||
export interface HighlightActionDescriptor { | ||
name: "highlight"; | ||
highlightId?: string; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export interface EditNewActionDescriptor { | ||
name: "editNew"; | ||
destination: DestinationDescriptor; | ||
} | ||
|
||
export interface GetTextActionOptions { | ||
showDecorations?: boolean; | ||
ensureSingleTarget?: boolean; | ||
} | ||
|
||
export interface GetTextActionDescriptor { | ||
name: "getText"; | ||
options?: GetTextActionOptions; | ||
target: PartialTargetDescriptor; | ||
} | ||
|
||
export type ActionDescriptor = | ||
| SimpleActionDescriptor | ||
| BringMoveActionDescriptor | ||
| SwapActionDescriptor | ||
| CallActionDescriptor | ||
| PasteActionDescriptor | ||
| ExecuteCommandActionDescriptor | ||
| ReplaceActionDescriptor | ||
| HighlightActionDescriptor | ||
| GenerateSnippetActionDescriptor | ||
| InsertSnippetActionDescriptor | ||
| WrapWithSnippetActionDescriptor | ||
| WrapWithPairedDelimiterActionDescriptor | ||
| EditNewActionDescriptor | ||
| GetTextActionDescriptor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { ActionDescriptor } from "./ActionDescriptor"; | ||
|
||
export interface CommandV6 { | ||
/** | ||
* The version number of the command API | ||
*/ | ||
version: 6; | ||
|
||
/** | ||
* The spoken form of the command if issued from a voice command system | ||
*/ | ||
spokenForm?: string; | ||
|
||
/** | ||
* If the command is issued from a voice command system, this boolean indicates | ||
* whether we should use the pre phrase snapshot. Only set this to true if the | ||
* voice command system issues a pre phrase signal at the start of every | ||
* phrase. | ||
*/ | ||
usePrePhraseSnapshot: boolean; | ||
|
||
/** | ||
* The action to perform. This field contains everything necessary to actually | ||
* perform the action. The other fields are just metadata. | ||
*/ | ||
action: ActionDescriptor; | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/common/src/types/command/DestinationDescriptor.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
PartialListTargetDescriptor, | ||
PartialPrimitiveTargetDescriptor, | ||
PartialRangeTargetDescriptor, | ||
} from "./PartialTargetDescriptor.types"; | ||
|
||
/** | ||
* The insertion mode to use when inserting relative to a target. | ||
* - `before` inserts before the target. Depending on the target, a delimiter | ||
* may be inserted after the inserted text. | ||
* - `after` inserts after the target. Depending on the target, a delimiter may | ||
* be inserted before the inserted text. | ||
* - `to` replaces the target. However, this insertion mode may also be used | ||
* when the target is really only a pseudo-target. For example, you could say | ||
* `"bring type air to bat"` even if `bat` doesn't already have a type. In | ||
* that case, `"take type bat"` wouldn't work, so `"type bat"` is really just | ||
* a pseudo-target in that situation. | ||
*/ | ||
export type InsertionMode = "before" | "after" | "to"; | ||
|
||
export interface PrimitiveDestinationDescriptor { | ||
type: "primitive"; | ||
|
||
/** | ||
* The insertion mode to use when inserting relative to {@link target}. | ||
*/ | ||
insertionMode: InsertionMode; | ||
|
||
target: | ||
| PartialPrimitiveTargetDescriptor | ||
| PartialRangeTargetDescriptor | ||
| PartialListTargetDescriptor; | ||
} | ||
|
||
/** | ||
* A list of destinations. This is used when the user uses more than one insertion mode | ||
* in a single command. For example, `"bring air after bat and before cap"`. | ||
*/ | ||
export interface ListDestinationDescriptor { | ||
type: "list"; | ||
destinations: PrimitiveDestinationDescriptor[]; | ||
} | ||
|
||
/** | ||
* An implicit destination. This is used for e.g. `"bring air"` (note the user | ||
* doesn't explicitly specify the destination), or `"snip funk"`. | ||
*/ | ||
export interface ImplicitDestinationDescriptor { | ||
type: "implicit"; | ||
} | ||
|
||
export type DestinationDescriptor = | ||
| ListDestinationDescriptor | ||
| PrimitiveDestinationDescriptor | ||
| ImplicitDestinationDescriptor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.