Skip to content

Commit 2664ea9

Browse files
Added support for python pattern list as collection item (#2483)
## 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 0a70357 commit 2664ea9

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
for key, value in map.items():
2+
pass
3+
---
4+
5+
[Range] =
6+
[Domain] = 0:4-0:14
7+
>----------<
8+
0| for key, value in map.items():
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
for key, value in map.items():
2+
pass
3+
---
4+
5+
[#1 Content] =
6+
[#1 Domain] = 0:4-0:7
7+
>---<
8+
0| for key, value in map.items():
9+
10+
[#1 Removal] = 0:4-0:9
11+
>-----<
12+
0| for key, value in map.items():
13+
14+
[#1 Trailing delimiter] = 0:7-0:9
15+
>--<
16+
0| for key, value in map.items():
17+
18+
[#1 Insertion delimiter] = ", "
19+
20+
21+
[#2 Content] =
22+
[#2 Domain] = 0:9-0:14
23+
>-----<
24+
0| for key, value in map.items():
25+
26+
[#2 Removal] = 0:7-0:14
27+
>-------<
28+
0| for key, value in map.items():
29+
30+
[#2 Leading delimiter] = 0:7-0:9
31+
>--<
32+
0| for key, value in map.items():
33+
34+
[#2 Insertion delimiter] = ", "

queries/python.scm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,19 @@
548548
(#insertion-delimiter! @collectionItem ", ")
549549
)
550550

551+
;;!! for key, value in map.items():
552+
;;! ^^^ ^^^^^
553+
(
554+
(pattern_list
555+
(identifier)? @_.leading.endOf
556+
.
557+
(identifier) @collectionItem
558+
.
559+
(identifier)? @_.trailing.startOf
560+
)
561+
(#insertion-delimiter! @collectionItem ", ")
562+
)
563+
551564
(import_statement
552565
.
553566
(_) @collectionItem.iteration.start.startOf
@@ -563,6 +576,9 @@
563576
.
564577
(_) @collectionItem.iteration.start.startOf
565578
) @collectionItem.iteration.end.endOf @collectionItem.iteration.domain
579+
580+
(pattern_list) @collectionItem.iteration
581+
566582
;;!! def foo(name) {}
567583
;;! ^^^^
568584
(

0 commit comments

Comments
 (0)