Skip to content

Commit f9a48b7

Browse files
committed
Fixes shorthand property assignment followed by comment
Fixes #666
1 parent c3f5259 commit f9a48b7

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,12 +1299,12 @@ repository:
12991299
patterns:
13001300
- include: '#expression'
13011301
- name: meta.object.member.ts
1302-
match: ({{identifier}})\s*(?=,|\}|$)
1302+
match: ({{identifier}})\s*(?=,|\}|$|\/\/|\/\*)
13031303
captures:
13041304
'1': { name: variable.other.readwrite.ts }
13051305
- name: meta.object.member.ts
13061306
begin: (?={{identifier}}\s*=)
1307-
end: (?=,|\}|$)
1307+
end: (?=,|\}|$|\/\/|\/\*)
13081308
patterns:
13091309
- include: '#expression'
13101310
# object member body:

TypeScript.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,7 @@
42104210
<key>name</key>
42114211
<string>meta.object.member.ts</string>
42124212
<key>match</key>
4213-
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)</string>
4213+
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$|\/\/|\/\*)</string>
42144214
<key>captures</key>
42154215
<dict>
42164216
<key>1</key>
@@ -4226,7 +4226,7 @@
42264226
<key>begin</key>
42274227
<string>(?=[_$[:alpha:]][_$[:alnum:]]*\s*=)</string>
42284228
<key>end</key>
4229-
<string>(?=,|\}|$)</string>
4229+
<string>(?=,|\}|$|\/\/|\/\*)</string>
42304230
<key>patterns</key>
42314231
<array>
42324232
<dict>

TypeScriptReact.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,7 @@
42144214
<key>name</key>
42154215
<string>meta.object.member.tsx</string>
42164216
<key>match</key>
4217-
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)</string>
4217+
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$|\/\/|\/\*)</string>
42184218
<key>captures</key>
42194219
<dict>
42204220
<key>1</key>
@@ -4230,7 +4230,7 @@
42304230
<key>begin</key>
42314231
<string>(?=[_$[:alpha:]][_$[:alnum:]]*\s*=)</string>
42324232
<key>end</key>
4233-
<string>(?=,|\}|$)</string>
4233+
<string>(?=,|\}|$|\/\/|\/\*)</string>
42344234
<key>patterns</key>
42354235
<array>
42364236
<dict>

tests/baselines/Issue666.baseline.txt

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ original file
33
switch (0) // discard and renew state per mode
44
{
55
}
6+
this.foo({
7+
one, two, three // some comment
8+
})
69
-----------------------------------
710

811
Grammar: TypeScript.tmLanguage
@@ -29,4 +32,43 @@ Grammar: TypeScript.tmLanguage
2932
source.ts switch-statement.expr.ts switch-block.expr.ts punctuation.definition.block.ts
3033
>}
3134
^
32-
source.ts switch-statement.expr.ts punctuation.definition.block.ts
35+
source.ts switch-statement.expr.ts punctuation.definition.block.ts
36+
>this.foo({
37+
^^^^
38+
source.ts meta.function-call.ts variable.language.this.ts
39+
^
40+
source.ts meta.function-call.ts punctuation.accessor.ts
41+
^^^
42+
source.ts meta.function-call.ts entity.name.function.ts
43+
^
44+
source.ts meta.brace.round.ts
45+
^
46+
source.ts meta.objectliteral.ts punctuation.definition.block.ts
47+
> one, two, three // some comment
48+
^^^
49+
source.ts meta.objectliteral.ts
50+
^^^
51+
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
52+
^
53+
source.ts meta.objectliteral.ts punctuation.separator.comma.ts
54+
^
55+
source.ts meta.objectliteral.ts
56+
^^^
57+
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
58+
^
59+
source.ts meta.objectliteral.ts punctuation.separator.comma.ts
60+
^
61+
source.ts meta.objectliteral.ts
62+
^^^^^
63+
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
64+
^
65+
source.ts meta.objectliteral.ts meta.object.member.ts
66+
^^
67+
source.ts meta.objectliteral.ts comment.line.double-slash.ts punctuation.definition.comment.ts
68+
^^^^^^^^^^^^^
69+
source.ts meta.objectliteral.ts comment.line.double-slash.ts
70+
>})
71+
^
72+
source.ts meta.objectliteral.ts punctuation.definition.block.ts
73+
^
74+
source.ts meta.brace.round.ts

tests/cases/Issue666.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
switch (0) // discard and renew state per mode
22
{
3-
}
3+
}
4+
this.foo({
5+
one, two, three // some comment
6+
})

0 commit comments

Comments
 (0)