fixing issue #454 single-line function with single-line if/else

This commit is contained in:
Jeremy Ashkenas 2010-06-26 17:20:13 -04:00
parent f7345ffaac
commit 698784e103
2 changed files with 2 additions and 2 deletions

View File

@ -246,7 +246,7 @@
idx += 1;
tok = this.tokens[idx];
pre = this.tokens[idx - 1];
if ((!tok || (include(SINGLE_CLOSERS, tok[0]) && tok[1] !== ';' && parens === 0) || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) {
if ((!tok || (include(SINGLE_CLOSERS, tok[0]) && tok[1] !== ';' && parens === 0) || (tok[0] === ')' && parens === 0)) && !(tok[0] === 'ELSE' && !('IF' === starter || 'THEN' === starter))) {
insertion = pre[0] === "," ? idx - 1 : idx;
outdent = ['OUTDENT', 2, token[2]];
outdent.generated = true;

View File

@ -174,7 +174,7 @@ exports.Rewriter: class Rewriter
if (not tok 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')
not (tok[0] is 'ELSE' and starter not in ['IF', 'THEN'])
insertion: if pre[0] is "," then idx - 1 else idx
outdent: ['OUTDENT', 2, token[2]]
outdent.generated: true