Skip to content

Commit ba1e073

Browse files
committed
Add scope for label name if identifier follows break/continue/goto
1 parent 612844a commit ba1e073

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ repository:
155155
- include: '#for-loop'
156156
- name: keyword.control.trycatch.ts
157157
match: '{{startOfIdentifier}}(catch|finally|throw|try){{endOfIdentifier}}'
158+
- match: '{{startOfIdentifier}}(break|continue|goto)\s+({{identifier}}){{endOfIdentifier}}'
159+
captures:
160+
'1': { name: keyword.control.loop.ts }
161+
'2': { name: entity.name.label.ts }
158162
- name: keyword.control.loop.ts
159163
match: '{{startOfIdentifier}}(break|continue|do|goto|while){{endOfIdentifier}}'
160164
- name: keyword.control.flow.ts

TypeScript.tmLanguage

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@
153153
<key>match</key>
154154
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
155155
</dict>
156+
<dict>
157+
<key>match</key>
158+
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(break|continue|goto)\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
159+
<key>captures</key>
160+
<dict>
161+
<key>1</key>
162+
<dict>
163+
<key>name</key>
164+
<string>keyword.control.loop.ts</string>
165+
</dict>
166+
<key>2</key>
167+
<dict>
168+
<key>name</key>
169+
<string>entity.name.label.ts</string>
170+
</dict>
171+
</dict>
172+
</dict>
156173
<dict>
157174
<key>name</key>
158175
<string>keyword.control.loop.ts</string>

TypeScriptReact.tmLanguage

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@
153153
<key>match</key>
154154
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
155155
</dict>
156+
<dict>
157+
<key>match</key>
158+
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(break|continue|goto)\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
159+
<key>captures</key>
160+
<dict>
161+
<key>1</key>
162+
<dict>
163+
<key>name</key>
164+
<string>keyword.control.loop.tsx</string>
165+
</dict>
166+
<key>2</key>
167+
<dict>
168+
<key>name</key>
169+
<string>entity.name.label.tsx</string>
170+
</dict>
171+
</dict>
172+
</dict>
156173
<dict>
157174
<key>name</key>
158175
<string>keyword.control.loop.tsx</string>

tests/baselines/Issue610.baseline.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Grammar: TypeScript.tmLanguage
9696
^
9797
source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.block.ts
9898
^^^^
99-
source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.block.ts variable.other.readwrite.ts
99+
source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.block.ts entity.name.label.ts
100100
^
101101
source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.block.ts punctuation.terminator.statement.ts
102102
> }

0 commit comments

Comments
 (0)