Skip to content

Commit fed8160

Browse files
committed
new operator can end at another new operator
Fixes #139
1 parent 7dbf74c commit fed8160

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ repository:
924924
beginCaptures:
925925
'1': { name: keyword.operator.new.ts }
926926
# new-expr ends just before any type or call arguments. Type arguments will be picked up by #cast.
927-
end: '(?=[(;),]|$)'
927+
end: '(?=[(;),]|$|((?<!\.|\$)\bnew\b(?!\$)))'
928928
patterns:
929929
- include: '#type'
930930

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@
21852185
</dict>
21862186
</dict>
21872187
<key>end</key>
2188-
<string>(?=[(;),]|$)</string>
2188+
<string>(?=[(;),]|$|((?&lt;!\.|\$)\bnew\b(?!\$)))</string>
21892189
<key>name</key>
21902190
<string>new.expr.ts</string>
21912191
<key>patterns</key>

TypeScriptReact.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ repository:
913913
beginCaptures:
914914
'1': { name: keyword.operator.new.tsx }
915915
# new-expr ends just before any type or call arguments. Type arguments will be picked up by #cast.
916-
end: '(?=[(;),]|$)'
916+
end: '(?=[(;),]|$|((?<!\.|\$)\bnew\b(?!\$)))'
917917
patterns:
918918
- include: '#type'
919919

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,7 @@
25712571
</dict>
25722572
</dict>
25732573
<key>end</key>
2574-
<string>(?=[(;),]|$)</string>
2574+
<string>(?=[(;),]|$|((?&lt;!\.|\$)\bnew\b(?!\$)))</string>
25752575
<key>name</key>
25762576
<string>new.expr.tsx</string>
25772577
<key>patterns</key>

tests/baselines/Issue139.baseline.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
original file
2+
-----------------------------------
3+
new new Proxy(function fn() {
4+
console.log(this.constructor.name);
5+
}, {});
6+
-----------------------------------
7+
8+
>new new Proxy(function fn() {
9+
^^^
10+
source.ts new.expr.ts keyword.operator.new.ts
11+
^
12+
source.ts new.expr.ts
13+
^^^
14+
source.ts new.expr.ts keyword.operator.new.ts
15+
^
16+
source.ts new.expr.ts
17+
^^^^^
18+
source.ts new.expr.ts entity.name.type.ts
19+
^
20+
source.ts meta.brace.round.ts
21+
^^^^^^^^
22+
source.ts meta.function.ts storage.type.function.ts
23+
^
24+
source.ts meta.function.ts
25+
^^
26+
source.ts meta.function.ts entity.name.function.ts
27+
^
28+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
29+
^
30+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
31+
^
32+
source.ts meta.function.ts
33+
^
34+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
35+
^^
36+
source.ts meta.function.ts meta.block.ts
37+
> console.log(this.constructor.name);
38+
^^^^^^^^^^^^^^^
39+
source.ts meta.function.ts meta.block.ts
40+
^
41+
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
42+
^^^^
43+
source.ts meta.function.ts meta.block.ts variable.language.this.ts
44+
^^^^^^^^^^^^^^^^^
45+
source.ts meta.function.ts meta.block.ts
46+
^
47+
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
48+
^^^
49+
source.ts meta.function.ts meta.block.ts
50+
>}, {});
51+
^
52+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
53+
^^
54+
source.ts
55+
^
56+
source.ts meta.object-literal.ts punctuation.definition.block.ts
57+
^
58+
source.ts meta.object-literal.ts punctuation.definition.block.ts
59+
^
60+
source.ts meta.brace.round.ts
61+
^^
62+
source.ts

tests/cases/Issue139.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
new new Proxy(function fn() {
2+
console.log(this.constructor.name);
3+
}, {});

0 commit comments

Comments
 (0)