Skip to content
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

Merged
merged 4 commits into from
Sep 21, 2022

Conversation

pokey
Copy link
Member

@pokey pokey commented Sep 13, 2022

This PR is the first step towards adding smarter that marks (#466). It adds the infrastructure so that actions can return smarter that marks, and allows us to test this behaviour, but for readability, it doesn't actually modify any targets to return smarter that 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

  • Stop removing fields equal to their defaults
  • Add new PR which removes that mark from all tests except for tests in action/ directory and makes that mark optional in recorded tests
  • Add new PR which adds support for excluding / including that marks in tests (defaults to excluding), adds ability to include recording test config in a directory, adding config to include that marks in action directory. Make it recursive with parents
  • I have added tests

@pokey pokey marked this pull request as draft September 14, 2022 09:49
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from 2c5c603 to cee3583 Compare September 18, 2022 14:32
@pokey pokey changed the title Smarter that mark for setSelection and highlight Initial work for smarter that marks Sep 18, 2022
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch 6 times, most recently from 067accf to 38872e7 Compare September 18, 2022 15:53
@@ -261,7 +261,7 @@ class BringMoveSwap implements Action {

await this.decorateThatMark(thatMark);

return { thatMark, sourceMark };
return { thatSelections: thatMark, sourceSelections: sourceMark };
Copy link
Member Author

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"
Copy link
Member Author

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";
Copy link
Member Author

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(
Copy link
Member Author

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";
Copy link
Member Author

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,
Copy link
Member Author

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";
Copy link
Member Author

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:
Copy link
Member Author

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

Comment on lines +82 to +85
const initialThatTargets = fixture.initialState.thatMark.map((mark) =>
plainObjectToTarget(editor, mark)
);
cursorlessApi.thatMark.set(initialThatTargets);
Copy link
Member Author

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

Comment on lines +45 to +46
thatMark: Target[];
sourceMark: Target[];
Copy link
Member Author

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

@pokey pokey marked this pull request as ready for review September 18, 2022 15:54
phillco
phillco previously approved these changes Sep 18, 2022
Copy link
Member

@phillco phillco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ship it

@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from 38872e7 to 70a0526 Compare September 19, 2022 18:13
@pokey pokey changed the base branch from main to pokey/remove-that-mark-from-non-action-tests September 19, 2022 18:14
@pokey pokey marked this pull request as draft September 20, 2022 09:44
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from 70a0526 to bc1b679 Compare September 21, 2022 11:53
Base automatically changed from pokey/remove-that-mark-from-non-action-tests to main September 21, 2022 12:33
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from bc1b679 to 7ac6044 Compare September 21, 2022 13:04
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from 7ac6044 to a1bcd50 Compare September 21, 2022 13:21
@pokey pokey force-pushed the pokey/partial-smarter-that-marks branch from a1bcd50 to fd2b692 Compare September 21, 2022 13:37
@pokey pokey marked this pull request as ready for review September 21, 2022 13:40
@AndreasArvidsson AndreasArvidsson merged commit da757c2 into main Sep 21, 2022
@AndreasArvidsson AndreasArvidsson deleted the pokey/partial-smarter-that-marks branch September 21, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants