Skip to content

Commit

Permalink
Support value for typescript destruct pattern (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored Dec 5, 2023
1 parent 2a56990 commit ea039d3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
languageId: typescript
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: |
const { aaa: bbb } = ccc;
selections:
- anchor: {line: 0, character: 8}
active: {line: 0, character: 8}
marks: {}
finalState:
documentContents: |
const { aaa: } = ccc;
selections:
- anchor: {line: 0, character: 13}
active: {line: 0, character: 13}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: chuck key
action:
name: remove
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: collectionKey}
usePrePhraseSnapshot: true
initialState:
documentContents: "const { aaa: bbb } = ccc;"
selections:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
marks: {}
finalState:
documentContents: const { bbb } = ccc;
selections:
- anchor: {line: 0, character: 8}
active: {line: 0, character: 8}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: chuck value
action:
name: remove
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: "const { aaa: bbb } = ccc;"
selections:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
marks: {}
finalState:
documentContents: const { aaa } = ccc;
selections:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
8 changes: 8 additions & 0 deletions queries/javascript.core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@
"}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf
)

;;!! const { aaa: bbb } = ccc;
;;! ^^^
;;! --------
(pair_pattern
key: (_) @collectionKey @collectionKey.trailing.start.endOf @value.leading.start.endOf
value: (_) @value @collectionKey.trailing.end.startOf @value.leading.end.startOf
) @_.domain

;;!! "string"
;;!! `string`
;;! ^^^^^^^^
Expand Down

0 comments on commit ea039d3

Please sign in to comment.