Skip to content

Commit ea039d3

Browse files
Support value for typescript destruct pattern (#2087)
Fixes #2082 ## Checklist - [x] 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 2a56990 commit ea039d3

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: change value
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: value}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
const { aaa: bbb } = ccc;
16+
selections:
17+
- anchor: {line: 0, character: 8}
18+
active: {line: 0, character: 8}
19+
marks: {}
20+
finalState:
21+
documentContents: |
22+
const { aaa: } = ccc;
23+
selections:
24+
- anchor: {line: 0, character: 13}
25+
active: {line: 0, character: 13}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: chuck key
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: collectionKey}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: "const { aaa: bbb } = ccc;"
15+
selections:
16+
- anchor: {line: 0, character: 9}
17+
active: {line: 0, character: 9}
18+
marks: {}
19+
finalState:
20+
documentContents: const { bbb } = ccc;
21+
selections:
22+
- anchor: {line: 0, character: 8}
23+
active: {line: 0, character: 8}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: chuck value
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: value}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: "const { aaa: bbb } = ccc;"
15+
selections:
16+
- anchor: {line: 0, character: 9}
17+
active: {line: 0, character: 9}
18+
marks: {}
19+
finalState:
20+
documentContents: const { aaa } = ccc;
21+
selections:
22+
- anchor: {line: 0, character: 9}
23+
active: {line: 0, character: 9}

queries/javascript.core.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@
416416
"}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf
417417
)
418418

419+
;;!! const { aaa: bbb } = ccc;
420+
;;! ^^^
421+
;;! --------
422+
(pair_pattern
423+
key: (_) @collectionKey @collectionKey.trailing.start.endOf @value.leading.start.endOf
424+
value: (_) @value @collectionKey.trailing.end.startOf @value.leading.end.startOf
425+
) @_.domain
426+
419427
;;!! "string"
420428
;;!! `string`
421429
;;! ^^^^^^^^

0 commit comments

Comments
 (0)