Skip to content

Commit 22bf6ea

Browse files
committed
Fixes
1 parent d963952 commit 22bf6ea

File tree

5 files changed

+163
-76
lines changed

5 files changed

+163
-76
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
languageId: python
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+
if (x := 0) < 1:
16+
pass
17+
selections:
18+
- anchor: {line: 0, character: 4}
19+
active: {line: 0, character: 4}
20+
marks: {}
21+
finalState:
22+
documentContents: |-
23+
if (x := ) < 1:
24+
pass
25+
selections:
26+
- anchor: {line: 0, character: 9}
27+
active: {line: 0, character: 9}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: python
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+
match aaa:
16+
case {"bbb": ccc}:
17+
pass
18+
selections:
19+
- anchor: {line: 1, character: 10}
20+
active: {line: 1, character: 10}
21+
marks: {}
22+
finalState:
23+
documentContents: |-
24+
match aaa:
25+
case {"bbb": }:
26+
pass
27+
selections:
28+
- anchor: {line: 1, character: 17}
29+
active: {line: 1, character: 17}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
languageId: python
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: |-
15+
if (x := 0) < 1:
16+
pass
17+
selections:
18+
- anchor: {line: 0, character: 4}
19+
active: {line: 0, character: 4}
20+
marks: {}
21+
finalState:
22+
documentContents: |-
23+
if (x) < 1:
24+
pass
25+
selections:
26+
- anchor: {line: 0, character: 4}
27+
active: {line: 0, character: 4}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: python
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: |-
15+
match aaa:
16+
case {"bbb": ccc}:
17+
pass
18+
selections:
19+
- anchor: {line: 1, character: 10}
20+
active: {line: 1, character: 10}
21+
marks: {}
22+
finalState:
23+
documentContents: |-
24+
match aaa:
25+
case {"bbb"}:
26+
pass
27+
selections:
28+
- anchor: {line: 1, character: 10}
29+
active: {line: 1, character: 10}

queries/python.scm

Lines changed: 51 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -27,81 +27,56 @@
2727
(with_statement)
2828
] @statement
2929

30-
;; a = 25
31-
;; ^^
32-
;; xxxx
33-
;; ------
34-
(
35-
(assignment
36-
[
37-
"="
38-
] @_.leading
39-
right: (_) @value
40-
) @_.domain
41-
)
42-
43-
;; a /= 25
44-
;; ^^
45-
;; xxxxx
46-
;; -------
47-
(
48-
(augmented_assignment
49-
[
50-
"+="
51-
"-="
52-
"*="
53-
"/="
54-
"%="
55-
"//="
56-
"**="
57-
"&="
58-
"|="
59-
"^="
60-
"<<="
61-
">>="
62-
] @_.leading
63-
right: (_) @value
64-
) @_.domain
65-
)
30+
;;!! a = 25
31+
;;! ^^
32+
;;! xxxx
33+
;;! ------
34+
(assignment
35+
(_) @_.leading.start.endOf
36+
.
37+
right: (_) @value @_.leading.end.startOf
38+
) @_.domain
6639

67-
;; d = {"a": 1234}
68-
;; ^^^^
69-
;; xxxxxx
70-
;; ---------
71-
;;
72-
;; {value: key for (key, value) in d1.items()}
73-
;; ^^^
74-
;; xxxxx
75-
;; ----------
76-
(pair
77-
":" @_.leading
78-
value: (_) @value
40+
;;!! a /= 25
41+
;;! ^^
42+
;;! xxxxx
43+
;;! -------
44+
(augmented_assignment
45+
(_) @_.leading.start.endOf
46+
.
47+
right: (_) @value @_.leading.end.startOf
7948
) @_.domain
8049

81-
;; def func(value: str=""):
82-
;; ^^
83-
;; xxx
84-
;; -------------
85-
(parameters
50+
;;!! d = {"a": 1234}
51+
;;! ^^^^
52+
;;! xxxxxx
53+
;;! ---------
54+
;;!! {value: key for (key, value) in d1.items()}
55+
;;! ^^^
56+
;;! xxxxx
57+
;;! ----------
58+
;;!! def func(value: str=""):
59+
;;! ^^
60+
;;! xxx
61+
;;! -------------
62+
(
8663
(_
87-
"=" @_.leading
88-
value: (_) @value
64+
(_) @_.leading.start.endOf
65+
.
66+
value: (_) @value @_.leading.end.startOf
8967
) @_.domain
68+
(#not-type? @_.domain subscript)
9069
)
9170

92-
;; def func():
93-
;; return 1
94-
;; ^
95-
;; x
96-
;; --------
71+
;;!! return 1
72+
;;! ^
73+
;;! --------
9774
;;
9875
;; NOTE: in tree-sitter, both "return" and the "1" are children of `return_statement`
9976
;; but "return" is anonymous whereas "1" is named node, so no need to exclude explicitly
100-
(
101-
(return_statement
102-
(_) @value
103-
) @_.domain
104-
)
77+
(return_statement
78+
(_) @value
79+
) @_.domain
10580

10681
(
10782
(function_definition
@@ -136,24 +111,24 @@
136111
(module) @namedFunction.iteration @functionName.iteration
137112
(class_definition) @namedFunction.iteration @functionName.iteration
138113

139-
;; def foo():
140-
;; a = 0
141-
;; *****
142-
;; b = 1
143-
;; *****
144-
;; c = 2
145-
;; *****
114+
;;!! def foo():
115+
;;!! a = 0
116+
;;! <*****
117+
;;!! b = 1
118+
;;! *****
119+
;;!! c = 2
120+
;;! *****>
146121
(block) @statement.iteration @value.iteration
147122

148-
;; {"a": 1, "b": 2, "c": 3}
149-
;; **********************
123+
;;!! {"a": 1, "b": 2, "c": 3}
124+
;;! **********************
150125
(dictionary
151126
"{" @value.iteration.start.endOf
152127
"}" @value.iteration.end.startOf
153128
)
154129

155-
;; def func(a=0, b=1):
156-
;; ********
130+
;;!! def func(a=0, b=1):
131+
;;! ********
157132
(parameters
158133
"(" @value.iteration.start.endOf
159134
")" @value.iteration.end.startOf

0 commit comments

Comments
 (0)