Skip to content

Commit e7aa4da

Browse files
authored
Merge pull request #372 from Microsoft/forAwaitOf
Adds for-await-of
2 parents 7e9a0ce + dc10229 commit e7aa4da

File tree

5 files changed

+89
-4
lines changed

5 files changed

+89
-4
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,11 @@ repository:
10431043
- include: '#expression'
10441044

10451045
for-loop:
1046-
begin: (?<!\.|\$)\b(for)\s*(\()
1046+
begin: (?<!\.|\$)\b(for)(?:\s+(await))?\s*(\()
10471047
beginCaptures:
10481048
'1': { name: keyword.control.loop.ts }
1049-
'2': { name: meta.brace.round.ts }
1049+
'2': { name: keyword.control.loop.ts }
1050+
'3': { name: meta.brace.round.ts }
10501051
end: \)
10511052
endCaptures:
10521053
'0': { name: meta.brace.round.ts }

TypeScript.tmLanguage

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,7 @@
31793179
<key>for-loop</key>
31803180
<dict>
31813181
<key>begin</key>
3182-
<string>(?&lt;!\.|\$)\b(for)\s*(\()</string>
3182+
<string>(?&lt;!\.|\$)\b(for)(?:\s+(await))?\s*(\()</string>
31833183
<key>beginCaptures</key>
31843184
<dict>
31853185
<key>1</key>
@@ -3188,6 +3188,11 @@
31883188
<string>keyword.control.loop.ts</string>
31893189
</dict>
31903190
<key>2</key>
3191+
<dict>
3192+
<key>name</key>
3193+
<string>keyword.control.loop.ts</string>
3194+
</dict>
3195+
<key>3</key>
31913196
<dict>
31923197
<key>name</key>
31933198
<string>meta.brace.round.ts</string>

TypeScriptReact.tmLanguage

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,7 @@
31833183
<key>for-loop</key>
31843184
<dict>
31853185
<key>begin</key>
3186-
<string>(?&lt;!\.|\$)\b(for)\s*(\()</string>
3186+
<string>(?&lt;!\.|\$)\b(for)(?:\s+(await))?\s*(\()</string>
31873187
<key>beginCaptures</key>
31883188
<dict>
31893189
<key>1</key>
@@ -3192,6 +3192,11 @@
31923192
<string>keyword.control.loop.tsx</string>
31933193
</dict>
31943194
<key>2</key>
3195+
<dict>
3196+
<key>name</key>
3197+
<string>keyword.control.loop.tsx</string>
3198+
</dict>
3199+
<key>3</key>
31953200
<dict>
31963201
<key>name</key>
31973202
<string>meta.brace.round.tsx</string>

tests/baselines/forof.baseline.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
original file
2+
-----------------------------------
3+
for (const x of y) {}
4+
for await (const x of y) {}
5+
-----------------------------------
6+
7+
Grammar: TypeScript.tmLanguage
8+
-----------------------------------
9+
>for (const x of y) {}
10+
^^^
11+
source.ts keyword.control.loop.ts
12+
^
13+
source.ts
14+
^
15+
source.ts meta.brace.round.ts
16+
^^^^^
17+
source.ts meta.var.expr.ts storage.type.ts
18+
^
19+
source.ts meta.var.expr.ts
20+
^
21+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
22+
^
23+
source.ts
24+
^^
25+
source.ts keyword.operator.expression.of.ts
26+
^
27+
source.ts
28+
^
29+
source.ts variable.other.readwrite.ts
30+
^
31+
source.ts meta.brace.round.ts
32+
^
33+
source.ts
34+
^
35+
source.ts meta.block.ts punctuation.definition.block.ts
36+
^
37+
source.ts meta.block.ts punctuation.definition.block.ts
38+
^^
39+
source.ts
40+
>for await (const x of y) {}
41+
^^^
42+
source.ts keyword.control.loop.ts
43+
^
44+
source.ts
45+
^^^^^
46+
source.ts keyword.control.loop.ts
47+
^
48+
source.ts
49+
^
50+
source.ts meta.brace.round.ts
51+
^^^^^
52+
source.ts meta.var.expr.ts storage.type.ts
53+
^
54+
source.ts meta.var.expr.ts
55+
^
56+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
57+
^
58+
source.ts
59+
^^
60+
source.ts keyword.operator.expression.of.ts
61+
^
62+
source.ts
63+
^
64+
source.ts variable.other.readwrite.ts
65+
^
66+
source.ts meta.brace.round.ts
67+
^
68+
source.ts
69+
^
70+
source.ts meta.block.ts punctuation.definition.block.ts
71+
^
72+
source.ts meta.block.ts punctuation.definition.block.ts

tests/cases/forof.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
for (const x of y) {}
2+
for await (const x of y) {}

0 commit comments

Comments
 (0)