Skip to content

Commit 39cb881

Browse files
committed
Fixed chaining semantics after outdent
1 parent 21db08a commit 39cb881

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

lib/coffee-script/rewriter.js

+3-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rewriter.coffee

+4-7
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

+7
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)