Skip to content

Commit c4d834c

Browse files
committed
Fix the type tokenization of instace of
Fixes #591
1 parent 24b8d8d commit c4d834c

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ repository:
11321132
begin: '{{startOfIdentifier}}(new){{endOfIdentifier}}'
11331133
beginCaptures:
11341134
'1': { name: keyword.operator.new.ts }
1135-
end: (?<=\))|(?=[;),}\]:]|$|({{startOfIdentifier}}new{{endOfIdentifier}})|({{startOfIdentifier}}function((\s+{{identifier}})|(\s*[\(]))))
1135+
end: (?<=\))|(?=[;),}\]:]|\|\||\&\&|$|({{startOfIdentifier}}new{{endOfIdentifier}})|({{startOfIdentifier}}function((\s+{{identifier}})|(\s*[\(]))))
11361136
patterns:
11371137
- include: '#paren-expression'
11381138
- include: '#class-declaration'
@@ -1142,7 +1142,7 @@ repository:
11421142
begin: '{{startOfIdentifier}}(instanceof){{endOfIdentifier}}'
11431143
beginCaptures:
11441144
'1': { name: keyword.operator.expression.instanceof.ts }
1145-
end: (?<=\))|(?=[;),}\]:]|$|({{startOfIdentifier}}function((\s+{{identifier}})|(\s*[\(]))))
1145+
end: (?<=\))|(?=[;),}\]:]|\|\||\&\&|$|({{startOfIdentifier}}function((\s+{{identifier}})|(\s*[\(]))))
11461146
patterns:
11471147
- include: '#type'
11481148

TypeScript.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,7 +3555,7 @@
35553555
</dict>
35563556
</dict>
35573557
<key>end</key>
3558-
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3558+
<string>(?&lt;=\))|(?=[;),}\]:]|\|\||\&amp;\&amp;|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
35593559
<key>patterns</key>
35603560
<array>
35613561
<dict>
@@ -3585,7 +3585,7 @@
35853585
</dict>
35863586
</dict>
35873587
<key>end</key>
3588-
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3588+
<string>(?&lt;=\))|(?=[;),}\]:]|\|\||\&amp;\&amp;|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
35893589
<key>patterns</key>
35903590
<array>
35913591
<dict>

TypeScriptReact.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,7 +3559,7 @@
35593559
</dict>
35603560
</dict>
35613561
<key>end</key>
3562-
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3562+
<string>(?&lt;=\))|(?=[;),}\]:]|\|\||\&amp;\&amp;|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
35633563
<key>patterns</key>
35643564
<array>
35653565
<dict>
@@ -3589,7 +3589,7 @@
35893589
</dict>
35903590
</dict>
35913591
<key>end</key>
3592-
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3592+
<string>(?&lt;=\))|(?=[;),}\]:]|\|\||\&amp;\&amp;|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
35933593
<key>patterns</key>
35943594
<array>
35953595
<dict>

tests/baselines/Issue591.baseline.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
original file
2+
-----------------------------------
3+
if (a instanceof B || c instanceof D) {
4+
}
5+
-----------------------------------
6+
7+
Grammar: TypeScript.tmLanguage
8+
-----------------------------------
9+
>if (a instanceof B || c instanceof D) {
10+
^^
11+
source.ts keyword.control.conditional.ts
12+
^
13+
source.ts
14+
^
15+
source.ts meta.brace.round.ts
16+
^
17+
source.ts variable.other.readwrite.ts
18+
^
19+
source.ts
20+
^^^^^^^^^^
21+
source.ts keyword.operator.expression.instanceof.ts
22+
^
23+
source.ts
24+
^
25+
source.ts entity.name.type.ts
26+
^
27+
source.ts
28+
^^
29+
source.ts keyword.operator.logical.ts
30+
^
31+
source.ts
32+
^
33+
source.ts variable.other.readwrite.ts
34+
^
35+
source.ts
36+
^^^^^^^^^^
37+
source.ts keyword.operator.expression.instanceof.ts
38+
^
39+
source.ts
40+
^
41+
source.ts entity.name.type.ts
42+
^
43+
source.ts meta.brace.round.ts
44+
^
45+
source.ts
46+
^
47+
source.ts meta.block.ts punctuation.definition.block.ts
48+
^^
49+
source.ts meta.block.ts
50+
>}
51+
^
52+
source.ts meta.block.ts punctuation.definition.block.ts

tests/cases/Issue591.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if (a instanceof B || c instanceof D) {
2+
}

0 commit comments

Comments
 (0)