Skip to content

Commit 990c98b

Browse files
Update typescript scopes (#2085)
Fixes #2072 Fixes #2083 Fixes #2033 ## 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 8abc5a4 commit 990c98b

File tree

6 files changed

+173
-10
lines changed

6 files changed

+173
-10
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 name
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
class Foo {
16+
bar
17+
}
18+
19+
selections:
20+
- anchor: {line: 1, character: 4}
21+
active: {line: 1, character: 4}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
class Foo {
26+
27+
}
28+
29+
selections:
30+
- anchor: {line: 1, character: 4}
31+
active: {line: 1, 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+
class Foo {
16+
bar: string;
17+
}
18+
19+
selections:
20+
- anchor: {line: 1, character: 4}
21+
active: {line: 1, character: 4}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
class Foo {
26+
bar: ;
27+
}
28+
29+
selections:
30+
- anchor: {line: 1, character: 9}
31+
active: {line: 1, character: 9}
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+
class Foo {
16+
bar(): string {}
17+
}
18+
19+
selections:
20+
- anchor: {line: 1, character: 4}
21+
active: {line: 1, character: 4}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
class Foo {
26+
bar(): {}
27+
}
28+
29+
selections:
30+
- anchor: {line: 1, character: 11}
31+
active: {line: 1, character: 11}
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+
interface Foo {
16+
bar: string;
17+
}
18+
selections:
19+
- anchor: {line: 1, character: 16}
20+
active: {line: 1, character: 16}
21+
marks: {}
22+
finalState:
23+
documentContents: |-
24+
interface Foo {
25+
bar: ;
26+
}
27+
selections:
28+
- anchor: {line: 1, character: 9}
29+
active: {line: 1, character: 9}
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 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+
class Foo {
16+
bar: string = "baz";
17+
}
18+
19+
selections:
20+
- anchor: {line: 1, character: 4}
21+
active: {line: 1, character: 4}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
class Foo {
26+
bar: string = ;
27+
}
28+
29+
selections:
30+
- anchor: {line: 1, character: 18}
31+
active: {line: 1, character: 18}

queries/typescript.core.scm

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@
6363
;;! -------------------------------^^^-------
6464
(public_field_definition
6565
name: (_) @name
66-
) @name.domain.start
66+
type: (_
67+
":"
68+
(_) @type
69+
)?
70+
value: (_)? @value
71+
) @_.domain.start
6772
.
68-
";"? @name.domain.end
73+
";"? @_.domain.end
6974
)
7075

7176
[
@@ -165,7 +170,9 @@
165170

166171
;;!! function ccc(): string {}
167172
;;! ^^^^^^
168-
(function_declaration
173+
;;!! ccc(): string {}
174+
;;! ^^^^^^
175+
(_
169176
parameters: (_) @type.leading.end.endOf
170177
return_type: (_
171178
":"
@@ -266,13 +273,16 @@
266273
;;! ^^^^
267274
;;! xxxxxx
268275
;;! ------------
269-
(property_signature
270-
name: (_) @collectionKey @collectionKey.trailing.start.endOf @type.leading.start.endOf
271-
type: (_
272-
":"
273-
(_) @type @collectionKey.trailing.end.startOf @type.leading.end.startOf
274-
)
275-
) @_.domain
276+
(
277+
(property_signature
278+
name: (_) @collectionKey @collectionKey.trailing.start.endOf @type.leading.start.endOf
279+
type: (_
280+
":"
281+
(_) @type @collectionKey.trailing.end.startOf @type.leading.end.startOf
282+
)
283+
) @_.domain.start
284+
";"? @_.domain.end
285+
)
276286

277287
;;!! interface Type { name: string; }
278288
;;! ^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)