Skip to content

Commit 54fa545

Browse files
committed
Fix groups vs. anonymous functions
This commit assumes parentheses as expression group until it being followed by an arrow.
1 parent 0083361 commit 54fa545

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

CoffeeScript.sublime-syntax

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ contexts:
148148
- match: (?=\()
149149
branch_point: anonymous
150150
branch:
151-
- anonymous-parameter-list
152151
- group
152+
- anonymous-parameter-list
153153
# named functions
154154
- match: (?=(?:(?!and=|or=)|@){{identifier}}\s*[:=][^>])
155155
branch_point: function
@@ -173,13 +173,23 @@ contexts:
173173
- match: '[=-]>'
174174
scope: meta.function.coffee keyword.declaration.function.coffee
175175
pop: 1
176-
- match: (?=\S)
177-
fail: anonymous
178176

179177
group:
180178
- match: \(
181179
scope: punctuation.section.group.begin.coffee
182-
pop: 1
180+
set: group-body
181+
182+
group-body:
183+
- meta_scope: meta.group.coffee
184+
- match: \)
185+
scope: punctuation.section.group.end.coffee
186+
set: group-check
187+
- include: expressions
188+
189+
group-check:
190+
- match: (?=[=-]>)
191+
fail: anonymous
192+
- include: else-pop
183193

184194
function-name:
185195
- meta_include_prototype: false

tests/syntax_test_scope.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,16 @@ class App.Router extends Snakeskin.Router
267267
->
268268
# ^^ keyword.declaration.function.coffee
269269

270+
(a : "group")
271+
# ^^^^^^^^^^^^^ meta.group.coffee
272+
# ^ punctuation.section.group.begin.coffee
273+
# ^ variable.other.readwrite.coffee
274+
# ^ keyword.operator.assignment.coffee
275+
# ^^^^^^^ meta.string.coffee string.quoted.double.coffee
276+
# ^ punctuation.definition.string.begin.coffee
277+
# ^ punctuation.definition.string.end.coffee
278+
# ^ punctuation.section.group.end.coffee
279+
270280
geometry = new Class();
271281
# ^^^^^^^^ variable.other.readwrite.coffee
272282
# ^ keyword.operator.assignment.coffee

0 commit comments

Comments
 (0)