Skip to content

Commit dada878

Browse files
authored
Fix "instance first three chars" (#1520)
The problem was that constructing a character range inadvertently resulted in a target with `isToken = true`, because when we clone the anchor target to create the new range target, we forgot to include the `isToken = false`. ## 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) - [ ] I have not broken the cheatsheet
1 parent ee3098d commit dada878

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ export default class PlainTarget extends BaseTarget {
2020
getTrailingDelimiterTarget = () => undefined;
2121
getRemovalRange = () => this.contentRange;
2222

23-
protected getCloneParameters = () => this.state;
23+
protected getCloneParameters() {
24+
return {
25+
...this.state,
26+
isToken: this.isToken,
27+
};
28+
}
2429
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
languageId: plaintext
2+
command:
3+
version: 5
4+
spokenForm: clear two instances first three cars air
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: relativeScope
10+
scopeType: {type: instance}
11+
offset: 0
12+
length: 2
13+
direction: forward
14+
- type: ordinalScope
15+
scopeType: {type: character}
16+
start: 0
17+
length: 3
18+
mark: {type: decoratedSymbol, symbolColor: default, character: a}
19+
usePrePhraseSnapshot: true
20+
initialState:
21+
documentContents: |
22+
aaabbb aaaccc
23+
selections:
24+
- anchor: {line: 1, character: 0}
25+
active: {line: 1, character: 0}
26+
marks:
27+
default.a:
28+
start: {line: 0, character: 0}
29+
end: {line: 0, character: 6}
30+
finalState:
31+
documentContents: |
32+
bbb ccc
33+
selections:
34+
- anchor: {line: 0, character: 0}
35+
active: {line: 0, character: 0}
36+
- anchor: {line: 0, character: 4}
37+
active: {line: 0, character: 4}

0 commit comments

Comments
 (0)