Skip to content

Commit f577cee

Browse files
Expand "type" to include generic type arguments / parameters (#2023)
- fixes #1231 ## 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 620c538 commit f577cee

File tree

16 files changed

+304
-12
lines changed

16 files changed

+304
-12
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: change type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
useState<string>()
16+
useState<Record<string, string>>()
17+
selections:
18+
- anchor: {line: 0, character: 9}
19+
active: {line: 0, character: 9}
20+
- anchor: {line: 1, character: 9}
21+
active: {line: 1, character: 9}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
useState<>()
26+
useState<>()
27+
selections:
28+
- anchor: {line: 0, character: 9}
29+
active: {line: 0, character: 9}
30+
- anchor: {line: 1, character: 9}
31+
active: {line: 1, character: 9}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: foo<Record<string, string>>()
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: foo<>()
21+
selections:
22+
- anchor: {line: 0, character: 4}
23+
active: {line: 0, character: 4}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: foo<string, string>()
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: foo<, string>()
21+
selections:
22+
- anchor: {line: 0, character: 4}
23+
active: {line: 0, character: 4}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: foo<string, string>()
15+
selections:
16+
- anchor: {line: 0, character: 12}
17+
active: {line: 0, character: 12}
18+
marks: {}
19+
finalState:
20+
documentContents: foo<string, >()
21+
selections:
22+
- anchor: {line: 0, character: 12}
23+
active: {line: 0, character: 12}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: Foo<string>()
15+
selections:
16+
- anchor: {line: 0, character: 4}
17+
active: {line: 0, character: 4}
18+
marks: {}
19+
finalState:
20+
documentContents: Foo<>()
21+
selections:
22+
- anchor: {line: 0, character: 4}
23+
active: {line: 0, character: 4}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: change type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |+
15+
function foo<A>() {
16+
17+
}
18+
19+
selections:
20+
- anchor: {line: 0, character: 13}
21+
active: {line: 0, character: 13}
22+
marks: {}
23+
finalState:
24+
documentContents: |+
25+
function foo<>() {
26+
27+
}
28+
29+
selections:
30+
- anchor: {line: 0, character: 13}
31+
active: {line: 0, character: 13}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: typescript
2+
command:
3+
version: 6
4+
spokenForm: change type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
const bar = <A>() => {
16+
17+
}
18+
selections:
19+
- anchor: {line: 0, character: 13}
20+
active: {line: 0, character: 13}
21+
marks: {}
22+
finalState:
23+
documentContents: |
24+
const bar = <>() => {
25+
26+
}
27+
selections:
28+
- anchor: {line: 0, character: 13}
29+
active: {line: 0, character: 13}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: "const foo: Record<string, string> = {}"
15+
selections:
16+
- anchor: {line: 0, character: 18}
17+
active: {line: 0, character: 18}
18+
marks: {}
19+
finalState:
20+
documentContents: "const foo: Record<, string> = {}"
21+
selections:
22+
- anchor: {line: 0, character: 18}
23+
active: {line: 0, character: 18}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: "const foo: string = new Bar<number>(foo);"
15+
selections:
16+
- anchor: {line: 0, character: 24}
17+
active: {line: 0, character: 24}
18+
marks: {}
19+
finalState:
20+
documentContents: "const foo: string = new (foo);"
21+
selections:
22+
- anchor: {line: 0, character: 24}
23+
active: {line: 0, character: 24}
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 type
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: type}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: "const foo: Bar<number> = new Bar<number>(foo);"
15+
selections:
16+
- anchor: {line: 0, character: 11}
17+
active: {line: 0, character: 11}
18+
marks: {}
19+
finalState:
20+
documentContents: "const foo: = new Bar<number>(foo);"
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}

0 commit comments

Comments
 (0)