From 6a059bfab70654f8616dfc07026944f18c1d081c Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 13 Jul 2010 23:33:59 -0400 Subject: [PATCH] fixing issue #497 try/catch/finally all empty. --- lib/rewriter.js | 2 +- src/rewriter.coffee | 3 ++- test/test_try_catch.coffee | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/rewriter.js b/lib/rewriter.js index 82311dd8..c98e3524 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -204,7 +204,7 @@ this.tokens.splice.apply(this.tokens, [i, 0].concat(this.indentation(token))); return 2; } - if (token[0] === 'CATCH' && this.tokens[i + 2][0] === 'TERMINATOR') { + if (token[0] === 'CATCH' && (this.tokens[i + 2][0] === 'TERMINATOR' || this.tokens[i + 2][0] === 'FINALLY')) { this.tokens.splice.apply(this.tokens, [i + 2, 0].concat(this.indentation(token))); return 4; } diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 62a004cf..6eda370b 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -159,7 +159,8 @@ exports.Rewriter: class Rewriter if token[0] is 'ELSE' and prev[0] isnt 'OUTDENT' @tokens.splice i, 0, @indentation(token)... return 2 - if token[0] is 'CATCH' and @tokens[i + 2][0] is 'TERMINATOR' + if token[0] is 'CATCH' and + (@tokens[i + 2][0] is 'TERMINATOR' or @tokens[i + 2][0] is 'FINALLY') @tokens.splice i + 2, 0, @indentation(token)... return 4 return 1 unless include(SINGLE_LINERS, token[0]) and diff --git a/test/test_try_catch.coffee b/test/test_try_catch.coffee index e5298aca..4d7bff12 100644 --- a/test/test_try_catch.coffee +++ b/test/test_try_catch.coffee @@ -35,4 +35,8 @@ try finally # nothing +try +catch err +finally + ok yes \ No newline at end of file