Skip to content

Commit 009dbac

Browse files
Return value for lambdas (#2086)
## 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 a4ab8da commit 009dbac

File tree

9 files changed

+161
-0
lines changed

9 files changed

+161
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: java
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: map(str -> str.length);
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: map(str -> );
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: java
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: map(str -> 0);
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: map(str -> );
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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: "map(lambda str: len(str))"
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: "map(lambda str: )"
21+
selections:
22+
- anchor: {line: 0, character: 16}
23+
active: {line: 0, character: 16}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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: "map(lambda str: 0)"
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: "map(lambda str: )"
21+
selections:
22+
- anchor: {line: 0, character: 16}
23+
active: {line: 0, character: 16}
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: 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: map(str => str.length)
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: map(str => )
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}
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: 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: map(str => 0)
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: map(str => )
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}

queries/java.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,11 @@
318318
(return_statement) @value @_.domain
319319
(#child-range! @value 1 -2)
320320
)
321+
322+
;;!! str -> str.length > 0
323+
;;! ^^^^^^^^^^^^^^
324+
;;! ---------------------
325+
(lambda_expression
326+
body: (_) @value
327+
(#not-type? @value block)
328+
) @_.domain

queries/javascript.core.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,14 @@
370370
(_) @value
371371
) @_.domain
372372

373+
;;!! str => str.length > 0
374+
;;! ^^^^^^^^^^^^^^
375+
;;! ---------------------
376+
(arrow_function
377+
body: (_) @value
378+
(#not-type? @value statement_block)
379+
) @_.domain
380+
373381
;; name:
374382
;;!! for (const aaa of bbb) {}
375383
;;! ^^^

queries/python.scm

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

145+
;;!! lambda str: len(str) > 0
146+
;;! ^^^^^^^^^^^^
147+
;;! ------------------------
148+
(lambda
149+
body: (_) @value
150+
) @_.domain
151+
145152
;; value:
146153
;;!! for aaa in bbb:
147154
;;! ^^^

0 commit comments

Comments
 (0)