Skip to content

Chaining semantics after arguments with outdent #3317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions lib/coffee-script/rewriter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions src/rewriter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,10 @@ class exports.Rewriter
# .g b
# .h a
#
if inImplicitCall() and tag in CALL_CLOSERS
if prevTag is 'OUTDENT'
endImplicitCall()
return forward(1)
if prevToken.newLine
endAllImplicitCalls()
return forward(1)
if inImplicitCall() and tag in CALL_CLOSERS and
(prevTag is 'OUTDENT' or prevToken.newLine)
endAllImplicitCalls()
return forward(1)

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

Expand Down
7 changes: 7 additions & 0 deletions test/formatting.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ test "#1495, method call chaining", ->
).join ', '
eq 'a, b, c', result

test "chaining after outdent", ->
str = 'abc'
zero = parseInt str.replace /\w/, (letter) ->
0
.toString()
eq '0', zero

# Operators

test "newline suppression for operators", ->
Expand Down