mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
Fixing the longstanding and important Issue #637. I'm glad this one got got.
This commit is contained in:
@@ -254,10 +254,10 @@
|
|||||||
if (noNewlines) {
|
if (noNewlines) {
|
||||||
return this.suppressNewlines();
|
return this.suppressNewlines();
|
||||||
}
|
}
|
||||||
this.outdebt = 0;
|
diff = size - this.indent + this.outdebt;
|
||||||
diff = size - this.indent;
|
|
||||||
this.token('INDENT', diff);
|
this.token('INDENT', diff);
|
||||||
this.indents.push(diff);
|
this.indents.push(diff);
|
||||||
|
this.outdebt = 0;
|
||||||
} else {
|
} else {
|
||||||
this.outdentToken(this.indent - size, noNewlines);
|
this.outdentToken(this.indent - size, noNewlines);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,10 +209,10 @@ exports.Lexer = class Lexer
|
|||||||
return @newlineToken indent
|
return @newlineToken indent
|
||||||
else if size > @indent
|
else if size > @indent
|
||||||
return @suppressNewlines() if noNewlines
|
return @suppressNewlines() if noNewlines
|
||||||
@outdebt = 0
|
diff = size - @indent + @outdebt
|
||||||
diff = size - @indent
|
|
||||||
@token 'INDENT', diff
|
@token 'INDENT', diff
|
||||||
@indents.push diff
|
@indents.push diff
|
||||||
|
@outdebt = 0
|
||||||
else
|
else
|
||||||
@outdentToken @indent - size, noNewlines
|
@outdentToken @indent - size, noNewlines
|
||||||
@indent = size
|
@indent = size
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ ok results.join(' ') is '1 4 9'
|
|||||||
# Chained blocks, with proper indentation levels:
|
# Chained blocks, with proper indentation levels:
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
counter = {
|
counter =
|
||||||
tick: (func) ->
|
tick: (func) ->
|
||||||
results.push func()
|
results.push func()
|
||||||
this
|
this
|
||||||
}
|
|
||||||
|
|
||||||
counter
|
counter
|
||||||
.tick ->
|
.tick ->
|
||||||
@@ -53,3 +52,17 @@ obj
|
|||||||
)
|
)
|
||||||
|
|
||||||
ok result is 3
|
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
|
x = 1
|
||||||
result = x + if false then 10 else 1
|
result = x + if false then 10 else 1
|
||||||
ok result is 2
|
ok result is 2
|
||||||
|
|
||||||
|
|
||||||
|
# If/else indented within an assignment.
|
||||||
|
func = ->
|
||||||
|
a =
|
||||||
|
if false
|
||||||
|
3
|
||||||
|
else
|
||||||
|
5
|
||||||
|
101
|
||||||
|
a
|
||||||
|
|
||||||
|
ok func() is 5
|
||||||
|
|||||||
Reference in New Issue
Block a user