From 561a02c35f80f55b6b32c7236410ab093dce3621 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 16 Feb 2010 14:56:17 -0500 Subject: [PATCH] updating rewrite rules for jots multiline function case --- lib/coffee_script/rewriter.js | 2 +- src/rewriter.coffee | 3 ++- src/underscore.coffee | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/coffee_script/rewriter.js b/lib/coffee_script/rewriter.js index 152f1e77..5b6c6e1f 100644 --- a/lib/coffee_script/rewriter.js +++ b/lib/coffee_script/rewriter.js @@ -249,7 +249,7 @@ while (true) { idx += 1; tok = this.tokens[idx]; - if ((!tok || SINGLE_CLOSERS.indexOf(tok[0]) >= 0 || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) { + if ((!tok || (SINGLE_CLOSERS.indexOf(tok[0]) >= 0 && tok[1] !== ';') || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) { insertion = this.tokens[idx - 1][0] === "," ? idx - 1 : idx; this.tokens.splice(insertion, 0, ['OUTDENT', 2, token[2]]); break; diff --git a/src/rewriter.coffee b/src/rewriter.coffee index b571636f..9f5e0f23 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -176,7 +176,8 @@ re::add_implicit_indentation: -> while true idx += 1 tok: @tokens[idx] - if (not tok or SINGLE_CLOSERS.indexOf(tok[0]) >= 0 or + if (not tok or + (SINGLE_CLOSERS.indexOf(tok[0]) >= 0 and tok[1] isnt ';') or (tok[0] is ')' && parens is 0)) and not (starter is 'ELSE' and tok[0] is 'ELSE') insertion: if @tokens[idx - 1][0] is "," then idx - 1 else idx diff --git a/src/underscore.coffee b/src/underscore.coffee index ac008e5f..e6a2b531 100644 --- a/src/underscore.coffee +++ b/src/underscore.coffee @@ -312,8 +312,8 @@ _.range: (start, stop, step) -> a: arguments solo: a.length <= 1 - i: start: if solo then 0 else a[0]; - stop: if solo then a[0] else a[1]; + i: start: if solo then 0 else a[0] + stop: if solo then a[0] else a[1] step: a[2] or 1 len: Math.ceil((stop - start) / step) return [] if len <= 0