Skip to content

Commit ae2c847

Browse files
committed
Handle comments in jsx
Fixes #585
1 parent f6c23ea commit ae2c847

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ repository:
149149
begin: \s+
150150
end: (?=[/]?>)
151151
patterns:
152+
- include: '#comment'
152153
- include: '#jsx-tag-attribute-name'
153154
- include: '#jsx-tag-attribute-assignment'
154155
- include: '#jsx-string-double-quoted'

TypeScriptReact.tmLanguage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7335,6 +7335,10 @@
73357335
<string>(?=[/]?&gt;)</string>
73367336
<key>patterns</key>
73377337
<array>
7338+
<dict>
7339+
<key>include</key>
7340+
<string>#comment</string>
7341+
</dict>
73387342
<dict>
73397343
<key>include</key>
73407344
<string>#jsx-tag-attribute-name</string>

tests/baselines/Issue585.baseline.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
original file
2+
-----------------------------------
3+
// @onlyOwnGrammar - As this has jsx
4+
const a = <button
5+
// disabled={false}
6+
/>
7+
-----------------------------------
8+
9+
Grammar: TypeScriptReact.tmLanguage
10+
-----------------------------------
11+
>// @onlyOwnGrammar - As this has jsx
12+
^^
13+
source.tsx comment.line.double-slash.tsx punctuation.definition.comment.tsx
14+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
source.tsx comment.line.double-slash.tsx
16+
>const a = <button
17+
^^^^^
18+
source.tsx meta.var.expr.tsx storage.type.tsx
19+
^
20+
source.tsx meta.var.expr.tsx
21+
^
22+
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx meta.definition.variable.tsx variable.other.readwrite.tsx
23+
^
24+
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx
25+
^
26+
source.tsx meta.var.expr.tsx keyword.operator.assignment.tsx
27+
^
28+
source.tsx meta.var.expr.tsx
29+
^
30+
source.tsx meta.var.expr.tsx meta.tag.tsx punctuation.definition.tag.begin.tsx
31+
^^^^^^
32+
source.tsx meta.var.expr.tsx meta.tag.tsx entity.name.tag.tsx
33+
^^^
34+
source.tsx meta.var.expr.tsx meta.tag.tsx meta.tag.attributes.tsx
35+
> // disabled={false}
36+
^^^^^^
37+
source.tsx meta.var.expr.tsx meta.tag.tsx meta.tag.attributes.tsx punctuation.whitespace.comment.leading.tsx
38+
^^
39+
source.tsx meta.var.expr.tsx meta.tag.tsx meta.tag.attributes.tsx comment.line.double-slash.tsx punctuation.definition.comment.tsx
40+
^^^^^^^^^^^^^^^^^^^
41+
source.tsx meta.var.expr.tsx meta.tag.tsx meta.tag.attributes.tsx comment.line.double-slash.tsx
42+
> />
43+
^^^^
44+
source.tsx meta.var.expr.tsx meta.tag.tsx meta.tag.attributes.tsx
45+
^^
46+
source.tsx meta.var.expr.tsx meta.tag.tsx punctuation.definition.tag.end.tsx

tests/cases/Issue585.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @onlyOwnGrammar - As this has jsx
2+
const a = <button
3+
// disabled={false}
4+
/>

0 commit comments

Comments
 (0)