Skip to content

Commit cc08411

Browse files
Add type scope support for typescript enum (#2772)
Fixes #1218 ## 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 3497e3d commit cc08411

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
enum Aaa {
2+
bbb,
3+
}
4+
---
5+
6+
[Content] =
7+
[Removal] =
8+
[Domain] = 0:0-2:1
9+
>----------
10+
0| enum Aaa {
11+
1| bbb,
12+
2| }
13+
-<
14+
15+
[Insertion delimiter] = " "
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const enum Aaa {
2+
bbb,
3+
}
4+
---
5+
6+
[Content] =
7+
[Removal] =
8+
[Domain] = 0:0-2:1
9+
>----------------
10+
0| const enum Aaa {
11+
1| bbb,
12+
2| }
13+
-<
14+
15+
[Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ export const scopeSupportFacetInfos: Record<
666666
description: "An interface declaration",
667667
scopeType: "type",
668668
},
669+
"type.enum": {
670+
description: "An enum declaration",
671+
scopeType: "type",
672+
},
669673
"type.class": {
670674
description: "An class declaration",
671675
scopeType: "type",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export const scopeSupportFacets = [
165165
"type.field.iteration",
166166
"type.foreach",
167167
"type.interface",
168+
"type.enum",
168169
"type.alias",
169170
"type.cast",
170171
"type.class",

packages/common/src/scopeSupportFacets/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = {
1919
"type.cast": supported,
2020
"type.field": supported,
2121
"type.interface": supported,
22+
"type.enum": supported,
2223
"type.return": supported,
2324
"type.variable": supported,
2425

queries/typescript.core.scm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
value: (_) @value
3535
) @_.domain
3636

37+
;;!! enum Aaa {}
38+
;;! ^^^^^^^^^^^
39+
(enum_declaration) @type
40+
3741
;;!! function aaa(bbb: Ccc = "ddd") {}
3842
;;! ^^^-------------
3943
(required_parameter

0 commit comments

Comments
 (0)