-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Initial work for smarter that
marks
#957
Conversation
2c5c603
to
cee3583
Compare
that
marks
067accf
to
38872e7
Compare
@@ -261,7 +261,7 @@ class BringMoveSwap implements Action { | |||
|
|||
await this.decorateThatMark(thatMark); | |||
|
|||
return { thatMark, sourceMark }; | |||
return { thatSelections: thatMark, sourceSelections: sourceMark }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We renamed thatMark
to thatSelections
. All changes to actions are just performing this rename
@@ -56,10 +56,41 @@ export type ActionType = | |||
| "wrapWithPairedDelimiter" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is important
@@ -1,10 +1,10 @@ | |||
import { SelectionWithEditor } from "../typings/Types"; | |||
import { Target } from "../typings/target.types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that now the ThatMark
class doesn't know anything about selections; felt specific to the CommandRunner
@@ -210,3 +220,20 @@ export default class CommandRunner { | |||
this.disposables.forEach(({ dispose }) => dispose()); | |||
} | |||
} | |||
|
|||
function constructThatTarget( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now where the logic lives for wrapping selections in a UntypedTarget
. Seemed better than spreading it out
@@ -1,9 +1,9 @@ | |||
import { Target } from "../../typings/target.types"; | |||
import type { Target } from "../../typings/target.types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through and added type
in a bunch of places
|
||
const AVAILABLE_TRANSFORMATIONS: Record<string, FixtureTransformation> = { | ||
upgrade, | ||
autoFormat: identity, | ||
// custom: MY_CUSTOM_TRANSFORMER, | ||
custom: upgradeThatMarks, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll revert this file before merging; it just imports the transformation I used on test cases
@@ -0,0 +1,48 @@ | |||
import { TestCaseFixture } from "../../testUtil/TestCase"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file will be reverted. It transforms all that
marks to be the UntypedTarget
that they would have become via ThatMarkStage
before.
@@ -50,11 +50,14 @@ finalState: | |||
- anchor: {line: 3, character: 0} | |||
active: {line: 3, character: 0} | |||
thatMark: | |||
- anchor: {line: 4, character: 15} | |||
active: {line: 4, character: 39} | |||
- contentRange: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tons of test case changes; worth a quick look at a few to get a flavour
const initialThatTargets = fixture.initialState.thatMark.map((mark) => | ||
plainObjectToTarget(editor, mark) | ||
); | ||
cursorlessApi.thatMark.set(initialThatTargets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note how we now rehydrate the that
mark to create a proper target
thatMark: Target[]; | ||
sourceMark: Target[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these are rich targets now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm ship it
38872e7
to
70a0526
Compare
70a0526
to
bc1b679
Compare
bc1b679
to
7ac6044
Compare
7ac6044
to
a1bcd50
Compare
a1bcd50
to
fd2b692
Compare
This PR is the first step towards adding smarter
that
marks (#466). It adds the infrastructure so that actions can return smarterthat
marks, and allows us to test this behaviour, but for readability, it doesn't actually modify any targets to return smarterthat
marks. Thus, this PR doesn't actually change Cursorless functionally at all.See also #965, which builds on this PR to add rich targets to a few easy actions
This PR builds on #967
Checklist
that
mark from all tests except for tests inaction/
directory and makes that mark optional in recorded tests