allowing chained calls broken up over multiple lines with periods at the front (jQuery-style)
This commit is contained in:
parent
7befbddae2
commit
2319affa61
|
@ -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
|
||||
|
|
|
@ -2,4 +2,23 @@ identity_wrap: x => => x
|
|||
|
||||
result: identity_wrap(identity_wrap(true))()()
|
||||
|
||||
print(result)
|
||||
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')
|
Loading…
Reference in New Issue