diff --git a/lib/coffee_script/lexer.rb b/lib/coffee_script/lexer.rb index 01adeefb..1b682a54 100644 --- a/lib/coffee_script/lexer.rb +++ b/lib/coffee_script/lexer.rb @@ -28,7 +28,7 @@ module CoffeeScript COMMENT = /\A(((\n?[ \t]*)?#.*$)+)/ CODE = /\A(=>)/ REGEX = /\A(\/(.*?)([^\\]|\\\\)\/[imgy]{0,4})/ - MULTI_DENT = /\A((\n([ \t]*)?)+)/ + MULTI_DENT = /\A((\n([ \t]*))+)(\.)?/ LAST_DENT = /\n([ \t]*)/ ASSIGNMENT = /\A(:|=)\Z/ @@ -139,7 +139,9 @@ module CoffeeScript return false unless indent = @chunk[MULTI_DENT, 1] @line += indent.scan(MULTILINER).size @i += indent.size - return suppress_newlines(indent) if last_value.to_s.match(NO_NEWLINE) && last_value != "=>" + next_character = @chunk[MULTI_DENT, 4] + no_newlines = next_character == '.' || (last_value.to_s.match(NO_NEWLINE) && last_value != "=>") + return suppress_newlines(indent) if no_newlines size = indent.scan(LAST_DENT).last.last.length return newline_token(indent) if size == @indent if size > @indent diff --git a/test/fixtures/execution/test_chained_calls.coffee b/test/fixtures/execution/test_chained_calls.coffee index 4cf76ec3..d48b50db 100644 --- a/test/fixtures/execution/test_chained_calls.coffee +++ b/test/fixtures/execution/test_chained_calls.coffee @@ -2,4 +2,23 @@ identity_wrap: x => => x result: identity_wrap(identity_wrap(true))()() -print(result) \ No newline at end of file +print(result) + + +str: 'god' + +result: str. + split(''). + reverse(). + reverse(). + reverse() + +print(result.join('') is 'dog') + +result: str + .split('') + .reverse() + .reverse() + .reverse() + +print(result.join('') is 'dog') \ No newline at end of file