Skip to content

Commit cf7b1ec

Browse files
committed
Handle inline comments when detecting arithmetic operator followed by number
Fixes #750
1 parent 42260eb commit cf7b1ec

File tree

6 files changed

+464
-87
lines changed

6 files changed

+464
-87
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,12 @@ repository:
16471647
- name: keyword.operator.arithmetic.ts
16481648
match: '%|\*|/|-|\+'
16491649
# capture the arithmetic sign followed by variable or parenthesized expression so that it is not interpreted as regex
1650+
- begin: (?<=[_$[:alnum:])\]])\s*(?=({{inlineComment}}\s*)+(/)(?![/*]))
1651+
end: (/)(?!\*([^\*]|(\*[^\/]))*\*\/)
1652+
endCaptures:
1653+
'1': { name: keyword.operator.arithmetic.ts }
1654+
patterns:
1655+
- include: '#comment'
16501656
- match: (?<=[_$[:alnum:])\]])\s*(/)(?![/*])
16511657
captures:
16521658
'1': { name: keyword.operator.arithmetic.ts }

TypeScript.tmLanguage

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5383,6 +5383,27 @@
53835383
<key>match</key>
53845384
<string>%|\*|/|-|\+</string>
53855385
</dict>
5386+
<dict>
5387+
<key>begin</key>
5388+
<string>(?&lt;=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))</string>
5389+
<key>end</key>
5390+
<string>(/)(?!\*([^\*]|(\*[^\/]))*\*\/)</string>
5391+
<key>endCaptures</key>
5392+
<dict>
5393+
<key>1</key>
5394+
<dict>
5395+
<key>name</key>
5396+
<string>keyword.operator.arithmetic.ts</string>
5397+
</dict>
5398+
</dict>
5399+
<key>patterns</key>
5400+
<array>
5401+
<dict>
5402+
<key>include</key>
5403+
<string>#comment</string>
5404+
</dict>
5405+
</array>
5406+
</dict>
53865407
<dict>
53875408
<key>match</key>
53885409
<string>(?&lt;=[_$[:alnum:])\]])\s*(/)(?![/*])</string>

TypeScriptReact.tmLanguage

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5305,6 +5305,27 @@
53055305
<key>match</key>
53065306
<string>%|\*|/|-|\+</string>
53075307
</dict>
5308+
<dict>
5309+
<key>begin</key>
5310+
<string>(?&lt;=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))</string>
5311+
<key>end</key>
5312+
<string>(/)(?!\*([^\*]|(\*[^\/]))*\*\/)</string>
5313+
<key>endCaptures</key>
5314+
<dict>
5315+
<key>1</key>
5316+
<dict>
5317+
<key>name</key>
5318+
<string>keyword.operator.arithmetic.tsx</string>
5319+
</dict>
5320+
</dict>
5321+
<key>patterns</key>
5322+
<array>
5323+
<dict>
5324+
<key>include</key>
5325+
<string>#comment</string>
5326+
</dict>
5327+
</array>
5328+
</dict>
53085329
<dict>
53095330
<key>match</key>
53105331
<string>(?&lt;=[_$[:alnum:])\]])\s*(/)(?![/*])</string>

0 commit comments

Comments
 (0)