Skip to content

Commit 383eb4c

Browse files
Use raw target that mark on remove action (#1270)
Fixes #1253 ## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] 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 4f36bad commit 383eb4c

File tree

10 files changed

+33
-31
lines changed

10 files changed

+33
-31
lines changed

src/actions/Clear.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ export default class Clear implements Action {
2424
}),
2525
);
2626

27-
const { thatSelections: thatMark } = await this.graph.actions.remove.run([
28-
plainTargets,
29-
]);
27+
const { thatTargets } = await this.graph.actions.remove.run([plainTargets]);
3028

31-
if (thatMark != null) {
29+
if (thatTargets != null) {
3230
await setSelectionsAndFocusEditor(
3331
ide().getEditableTextEditor(editor),
34-
thatMark.map(({ selection }) => selection),
32+
thatTargets.map(({ contentSelection }) => contentSelection),
3533
);
3634
}
3735

38-
return { thatSelections: thatMark };
36+
return { thatTargets };
3937
}
4038
}

src/actions/CutToClipboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ export class CutToClipboard implements Action {
5959

6060
await this.graph.actions.copyToClipboard.run([targets], options);
6161

62-
const { thatSelections: thatMark } = await this.graph.actions.remove.run(
62+
const { thatTargets } = await this.graph.actions.remove.run(
6363
[targets],
6464
options,
6565
);
6666

67-
return { thatSelections: thatMark };
67+
return { thatTargets };
6868
}
6969
}
7070

src/actions/Remove.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { flatten } from "lodash";
1+
import { flatten, zip } from "lodash";
22
import { performEditsAndUpdateRanges } from "../core/updateSelections/updateSelections";
33
import { FlashStyle } from "../libs/common/ide/types/FlashDescriptor";
44
import ide from "../libs/cursorless-engine/singletons/ide.singleton";
5+
import { RawSelectionTarget } from "../processTargets/targets";
56
import { Target } from "../typings/target.types";
67
import { Graph } from "../typings/Types";
7-
import {
8-
createThatMark,
9-
flashTargets,
10-
runOnTargetsForEachEditor,
11-
} from "../util/targetUtils";
8+
import { flashTargets, runOnTargetsForEachEditor } from "../util/targetUtils";
129
import { unifyRemovalTargets } from "../util/unifyRanges";
1310
import { Action, ActionReturnValue } from "./actions.types";
1411

@@ -30,7 +27,7 @@ export default class Delete implements Action {
3027
);
3128
}
3229

33-
const thatMark = flatten(
30+
const thatTargets = flatten(
3431
await runOnTargetsForEachEditor(targets, async (editor, targets) => {
3532
const edits = targets.map((target) => target.constructRemovalEdit());
3633
const ranges = edits.map((edit) => edit.range);
@@ -42,10 +39,17 @@ export default class Delete implements Action {
4239
[ranges],
4340
);
4441

45-
return createThatMark(targets, updatedRanges);
42+
return zip(targets, updatedRanges).map(
43+
([target, range]) =>
44+
new RawSelectionTarget({
45+
editor: target!.editor,
46+
isReversed: target!.isReversed,
47+
contentRange: range!,
48+
}),
49+
);
4650
}),
4751
);
4852

49-
return { thatSelections: thatMark };
53+
return { thatTargets };
5054
}
5155
}

src/test/suite/fixtures/recorded/actions/carveVest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ finalState:
2525
- anchor: {line: 0, character: 0}
2626
active: {line: 0, character: 0}
2727
thatMark:
28-
- type: UntypedTarget
28+
- type: RawSelectionTarget
2929
contentRange:
3030
start: {line: 1, character: 6}
3131
end: {line: 1, character: 6}
3232
isReversed: false
33-
hasExplicitRange: false
33+
hasExplicitRange: true
3434
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: v}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}]

src/test/suite/fixtures/recorded/actions/chuckArgMadeAndAir.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ finalState:
2929
- anchor: {line: 0, character: 0}
3030
active: {line: 0, character: 0}
3131
thatMark:
32-
- type: UntypedTarget
32+
- type: RawSelectionTarget
3333
contentRange:
3434
start: {line: 0, character: 29}
3535
end: {line: 0, character: 29}
3636
isReversed: false
37-
hasExplicitRange: false
37+
hasExplicitRange: true
3838
fullTargets: [{type: list, elements: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}]}]

src/test/suite/fixtures/recorded/actions/chuckArgMadeAndAirAndJustSoon.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ finalState:
3535
- anchor: {line: 0, character: 0}
3636
active: {line: 0, character: 0}
3737
thatMark:
38-
- type: UntypedTarget
38+
- type: RawSelectionTarget
3939
contentRange:
4040
start: {line: 0, character: 22}
4141
end: {line: 0, character: 22}
4242
isReversed: false
43-
hasExplicitRange: false
43+
hasExplicitRange: true
4444
fullTargets: [{type: list, elements: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: toRawSelection}, isImplicit: false}]}]

src/test/suite/fixtures/recorded/actions/chuckEveryArgMade.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ finalState:
2222
- anchor: {line: 0, character: 0}
2323
active: {line: 0, character: 0}
2424
thatMark:
25-
- type: UntypedTarget
25+
- type: RawSelectionTarget
2626
contentRange:
2727
start: {line: 0, character: 16}
2828
end: {line: 0, character: 16}
2929
isReversed: false
30-
hasExplicitRange: false
30+
hasExplicitRange: true
3131
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true}, isImplicit: false}]

src/test/suite/fixtures/recorded/actions/chuckVest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ finalState:
2525
- anchor: {line: 0, character: 0}
2626
active: {line: 0, character: 0}
2727
thatMark:
28-
- type: UntypedTarget
28+
- type: RawSelectionTarget
2929
contentRange:
3030
start: {line: 1, character: 6}
3131
end: {line: 1, character: 6}
3232
isReversed: false
33-
hasExplicitRange: false
33+
hasExplicitRange: true
3434
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: v}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: outside}]

src/test/suite/fixtures/recorded/actions/clearVest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ finalState:
2525
- anchor: {line: 1, character: 6}
2626
active: {line: 1, character: 6}
2727
thatMark:
28-
- type: UntypedTarget
28+
- type: RawSelectionTarget
2929
contentRange:
3030
start: {line: 1, character: 6}
3131
end: {line: 1, character: 6}
3232
isReversed: false
33-
hasExplicitRange: false
33+
hasExplicitRange: true
3434
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: v}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}]

src/test/suite/fixtures/recorded/actions/cutEveryArgMade.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ finalState:
2222
- anchor: {line: 0, character: 0}
2323
active: {line: 0, character: 0}
2424
thatMark:
25-
- type: UntypedTarget
25+
- type: RawSelectionTarget
2626
contentRange:
2727
start: {line: 0, character: 16}
2828
end: {line: 0, character: 16}
2929
isReversed: false
30-
hasExplicitRange: false
30+
hasExplicitRange: true
3131
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: true}, isImplicit: false}]

0 commit comments

Comments
 (0)