mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixing the longstanding and important Issue #637. I'm glad this one got got.
This commit is contained in:
parent
143c4d5efc
commit
d5d5de55ae
4 changed files with 32 additions and 6 deletions
|
@ -254,10 +254,10 @@
|
|||
if (noNewlines) {
|
||||
return this.suppressNewlines();
|
||||
}
|
||||
this.outdebt = 0;
|
||||
diff = size - this.indent;
|
||||
diff = size - this.indent + this.outdebt;
|
||||
this.token('INDENT', diff);
|
||||
this.indents.push(diff);
|
||||
this.outdebt = 0;
|
||||
} else {
|
||||
this.outdentToken(this.indent - size, noNewlines);
|
||||
}
|
||||
|
|
|
@ -209,10 +209,10 @@ exports.Lexer = class Lexer
|
|||
return @newlineToken indent
|
||||
else if size > @indent
|
||||
return @suppressNewlines() if noNewlines
|
||||
@outdebt = 0
|
||||
diff = size - @indent
|
||||
diff = size - @indent + @outdebt
|
||||
@token 'INDENT', diff
|
||||
@indents.push diff
|
||||
@outdebt = 0
|
||||
else
|
||||
@outdentToken @indent - size, noNewlines
|
||||
@indent = size
|
||||
|
|
|
@ -8,11 +8,10 @@ ok results.join(' ') is '1 4 9'
|
|||
# Chained blocks, with proper indentation levels:
|
||||
results = []
|
||||
|
||||
counter = {
|
||||
counter =
|
||||
tick: (func) ->
|
||||
results.push func()
|
||||
this
|
||||
}
|
||||
|
||||
counter
|
||||
.tick ->
|
||||
|
@ -53,3 +52,17 @@ obj
|
|||
)
|
||||
|
||||
ok result is 3
|
||||
|
||||
|
||||
# Test newline-supressed call chains with nested functions.
|
||||
obj =
|
||||
call: -> this
|
||||
func = ->
|
||||
obj
|
||||
.call ->
|
||||
one two
|
||||
.call ->
|
||||
three four
|
||||
101
|
||||
|
||||
ok func() is 101
|
||||
|
|
|
@ -96,3 +96,16 @@ catch e
|
|||
x = 1
|
||||
result = x + if false then 10 else 1
|
||||
ok result is 2
|
||||
|
||||
|
||||
# If/else indented within an assignment.
|
||||
func = ->
|
||||
a =
|
||||
if false
|
||||
3
|
||||
else
|
||||
5
|
||||
101
|
||||
a
|
||||
|
||||
ok func() is 5
|
||||
|
|
Loading…
Add table
Reference in a new issue