Skip to content

Commit 1cc583b

Browse files
committed
Merge pull request #3317 from xixixao/chainafteroutdent
Chaining semantics after arguments with outdent
2 parents 21db08a + 39cb881 commit 1cc583b

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

lib/coffee-script/rewriter.js

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rewriter.coffee

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,10 @@ class exports.Rewriter
286286
# .g b
287287
# .h a
288288
#
289-
if inImplicitCall() and tag in CALL_CLOSERS
290-
if prevTag is 'OUTDENT'
291-
endImplicitCall()
292-
return forward(1)
293-
if prevToken.newLine
294-
endAllImplicitCalls()
295-
return forward(1)
289+
if inImplicitCall() and tag in CALL_CLOSERS and
290+
(prevTag is 'OUTDENT' or prevToken.newLine)
291+
endAllImplicitCalls()
292+
return forward(1)
296293

297294
stackTop()[2].sameLine = no if inImplicitObject() and tag in LINEBREAKS
298295

test/formatting.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ test "#1495, method call chaining", ->
9898
).join ', '
9999
eq 'a, b, c', result
100100

101+
test "chaining after outdent", ->
102+
str = 'abc'
103+
zero = parseInt str.replace /\w/, (letter) ->
104+
0
105+
.toString()
106+
eq '0', zero
107+
101108
# Operators
102109

103110
test "newline suppression for operators", ->

0 commit comments

Comments
 (0)