Skip to content

Commit 71d0430

Browse files
committed
Make tags accomodate spaces
Fixes #264
1 parent 6349545 commit 71d0430

File tree

4 files changed

+79
-16
lines changed

4 files changed

+79
-16
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ repository:
105105

106106
jsx-tag-without-attributes:
107107
name: meta.tag.without-attributes.tsx
108-
begin: (<)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>)
109-
end: (</)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>)
108+
begin: (<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)
109+
end: (</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)
110110
beginCaptures:
111111
'1': {name: punctuation.definition.tag.begin.tsx}
112112
'2': {name: entity.name.tag.tsx}
@@ -124,12 +124,12 @@ repository:
124124
begin: >-
125125
(?x)
126126
(?<=[({\[,?=>]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
127-
(?!(<)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>)) #look ahead is not start of tag without attributes
128-
(?!<[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
129-
(?=(<)
127+
(?!(<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)) #look ahead is not start of tag without attributes
128+
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
129+
(?=(<)\s*
130130
([_$a-zA-Z][-$\w.]*(?<!\.|-))
131131
(?=\s+(?!\?)|/?>))
132-
end: (/>)|(?:(</)([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>))
132+
end: (/>)|(?:(</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>))
133133
endCaptures:
134134
'0': { name: meta.tag.tsx }
135135
'1': { name: punctuation.definition.tag.end.tsx }
@@ -140,13 +140,13 @@ repository:
140140
- name: meta.tag.tsx
141141
begin: >-
142142
(?x)
143-
(<)
143+
(<)\s*
144144
([_$a-zA-Z][-$\w.]*(?<!\.|-))
145145
(?=\s+(?!\?)|/?>)
146146
beginCaptures:
147147
'1': { name: punctuation.definition.tag.begin.tsx }
148148
'2': { name: entity.name.tag.tsx }
149-
end: (?=(/>)|(?:(</)([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
149+
end: (?=(/>)|(?:(</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
150150
patterns:
151151
- begin: \G(?![/]?>)
152152
end: (?=[/]?>)

TypeScriptReact.tmLanguage

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,9 +4476,9 @@
44764476
<key>name</key>
44774477
<string>meta.tag.without-attributes.tsx</string>
44784478
<key>begin</key>
4479-
<string>(&lt;)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))(&gt;)</string>
4479+
<string>(&lt;)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)</string>
44804480
<key>end</key>
4481-
<string>(&lt;/)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))(&gt;)</string>
4481+
<string>(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)</string>
44824482
<key>beginCaptures</key>
44834483
<dict>
44844484
<key>1</key>
@@ -4530,13 +4530,13 @@
45304530
<key>begin</key>
45314531
<string>(?x)
45324532
(?&lt;=[({\[,?=&gt;]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
4533-
(?!(&lt;)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))(&gt;)) #look ahead is not start of tag without attributes
4534-
(?!&lt;[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
4535-
(?=(&lt;)
4533+
(?!(&lt;)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)) #look ahead is not start of tag without attributes
4534+
(?!&lt;\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
4535+
(?=(&lt;)\s*
45364536
([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))
45374537
(?=\s+(?!\?)|/?&gt;))</string>
45384538
<key>end</key>
4539-
<string>(/&gt;)|(?:(&lt;/)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;))</string>
4539+
<string>(/&gt;)|(?:(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;))</string>
45404540
<key>endCaptures</key>
45414541
<dict>
45424542
<key>0</key>
@@ -4572,7 +4572,7 @@
45724572
<string>meta.tag.tsx</string>
45734573
<key>begin</key>
45744574
<string>(?x)
4575-
(&lt;)
4575+
(&lt;)\s*
45764576
([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))
45774577
(?=\s+(?!\?)|/?&gt;)</string>
45784578
<key>beginCaptures</key>
@@ -4589,7 +4589,7 @@
45894589
</dict>
45904590
</dict>
45914591
<key>end</key>
4592-
<string>(?=(/&gt;)|(?:(&lt;/)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)))</string>
4592+
<string>(?=(/&gt;)|(?:(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)))</string>
45934593
<key>patterns</key>
45944594
<array>
45954595
<dict>

tests/baselines/Issue264.baseline.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
original file
2+
-----------------------------------
3+
// @onlyOwnGrammar - As this has jsx
4+
<List>
5+
<div >
6+
</div>
7+
</List >
8+
-----------------------------------
9+
10+
Grammar: TypeScriptReact.tmLanguage
11+
-----------------------------------
12+
>// @onlyOwnGrammar - As this has jsx
13+
^^
14+
source.tsx comment.line.double-slash.tsx punctuation.definition.comment.tsx
15+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
source.tsx comment.line.double-slash.tsx
17+
><List>
18+
^
19+
source.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.begin.tsx
20+
^^^^
21+
source.tsx meta.tag.without-attributes.tsx entity.name.tag.tsx
22+
^
23+
source.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.end.tsx
24+
^^
25+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx
26+
> <div >
27+
^^
28+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx
29+
^
30+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.begin.tsx
31+
^^^
32+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx entity.name.tag.tsx
33+
^
34+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx
35+
^
36+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.end.tsx
37+
^^
38+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx
39+
> </div>
40+
^^
41+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx
42+
^^
43+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.begin.tsx
44+
^^^
45+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx entity.name.tag.tsx
46+
^
47+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.end.tsx
48+
^^
49+
source.tsx meta.tag.without-attributes.tsx meta.jsx.children.tsx
50+
></List >
51+
^^
52+
source.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.begin.tsx
53+
^^^^
54+
source.tsx meta.tag.without-attributes.tsx entity.name.tag.tsx
55+
^
56+
source.tsx meta.tag.without-attributes.tsx
57+
^
58+
source.tsx meta.tag.without-attributes.tsx punctuation.definition.tag.end.tsx

tests/cases/Issue264.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @onlyOwnGrammar - As this has jsx
2+
<List>
3+
<div >
4+
</div>
5+
</List >

0 commit comments

Comments
 (0)