Skip to content

Commit aed028e

Browse files
authored
Add support for yield statements for "value" in Python (#2215)
Fixes #2214 ## 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 be6ab53 commit aed028e

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

packages/common/src/scopeSupportFacets/python.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
1212
"name.resource": supported,
1313
"name.resource.iteration": supported,
1414
"value.foreach": supported,
15+
"value.yield": supported,
1516
"value.resource": supported,
1617
"value.resource.iteration": supported,
1718

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ export const scopeSupportFacetInfos: Record<
299299
description: "Value (RHS) of a field in a class / interface",
300300
scopeType: "value",
301301
},
302+
"value.yield": {
303+
description: "Value of a yield statement",
304+
scopeType: "value",
305+
},
302306
"value.resource": {
303307
description: "Value of a 'with' / 'use' / 'using' statement",
304308
scopeType: "value",

packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const scopeSupportFacets = [
7878
"value.return",
7979
"value.return.lambda",
8080
"value.field",
81+
"value.yield",
8182
"value.resource",
8283
"value.resource.iteration",
8384

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def aaa():
2+
yield bbb
3+
---
4+
5+
[Content] = 1:10-1:13
6+
1| yield bbb
7+
>---<
8+
9+
[Removal] = 1:9-1:13
10+
1| yield bbb
11+
>----<
12+
13+
[Leading delimiter] = 1:9-1:10
14+
1| yield bbb
15+
>-<
16+
17+
[Domain] = 1:4-1:13
18+
1| yield bbb
19+
>---------<
20+
21+
[Insertion delimiter] = " "

queries/python.scm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@
142142
(_) @value
143143
) @_.domain
144144

145+
;;!! yield 1
146+
;;! ^
147+
;;! xx
148+
;;! -------
149+
;;
150+
;; NOTE: in tree-sitter, both "yield" and the "1" are children of `yield` but
151+
;; "yield" is anonymous whereas "1" is named node, so no need to exclude
152+
;; explicitly
153+
(yield
154+
(_) @value
155+
) @_.domain
156+
145157
;;!! with aaa:
146158
;;! ^^^
147159
;;! --------

0 commit comments

Comments
 (0)