mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixing issue #396 ... issue with nested if/elses getting mis-nested.
This commit is contained in:
parent
a8db2bcf10
commit
b61399fbde
3 changed files with 8 additions and 2 deletions
|
@ -246,7 +246,7 @@
|
|||
idx += 1;
|
||||
tok = this.tokens[idx];
|
||||
pre = this.tokens[idx - 1];
|
||||
if ((!tok || (include(SINGLE_CLOSERS, tok[0]) && tok[1] !== ';') || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) {
|
||||
if ((!tok || (include(SINGLE_CLOSERS, tok[0]) && tok[1] !== ';' && parens === 0) || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) {
|
||||
insertion = pre[0] === "," ? idx - 1 : idx;
|
||||
outdent = ['OUTDENT', 2, token[2]];
|
||||
outdent.generated = true;
|
||||
|
|
|
@ -171,7 +171,7 @@ exports.Rewriter: class Rewriter
|
|||
tok: @tokens[idx]
|
||||
pre: @tokens[idx - 1]
|
||||
if (not tok or
|
||||
(include(SINGLE_CLOSERS, tok[0]) and tok[1] isnt ';') or
|
||||
(include(SINGLE_CLOSERS, tok[0]) and tok[1] isnt ';' and parens is 0) or
|
||||
(tok[0] is ')' and parens is 0)) and
|
||||
not (starter is 'ELSE' and tok[0] is 'ELSE')
|
||||
insertion: if pre[0] is "," then idx - 1 else idx
|
||||
|
|
|
@ -42,3 +42,9 @@ else
|
|||
11
|
||||
|
||||
ok result is 11
|
||||
|
||||
|
||||
# Nested inline if statements.
|
||||
echo: (x) -> x
|
||||
result: if true then echo((if false then 'xxx' else 'y') + 'a')
|
||||
ok result is 'ya'
|
||||
|
|
Loading…
Reference in a new issue