From 1f5727fe9ded214bc4f02efc46e43b4b7d525edc Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 28 Nov 2010 17:54:00 -0800 Subject: [PATCH] Coco 38aa762: rewriter: made addImplicitBraces consume multiple leading comments --- lib/rewriter.js | 2 +- src/rewriter.coffee | 4 ++-- test/test_literals.coffee | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rewriter.js b/lib/rewriter.js index f309bd99..0d70b015 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -138,7 +138,7 @@ } stack.push(['{']); idx = ago === '@' ? i - 2 : i - 1; - if (this.tag(idx - 2) === 'HERECOMMENT') { + while (this.tag(idx - 2) === 'HERECOMMENT') { idx -= 2; } value = new String('{'); diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 59776a50..7a4304ca 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -115,8 +115,8 @@ class exports.Rewriter return 1 unless tag is ':' and ((ago = @tag i - 2) is ':' or stack[stack.length - 1]?[0] isnt '{') stack.push ['{'] - idx = if ago is '@' then i - 2 else i - 1 - idx -= 2 if @tag(idx - 2) is 'HERECOMMENT' + idx = if ago is '@' then i - 2 else i - 1 + idx -= 2 while @tag(idx - 2) is 'HERECOMMENT' value = new String('{') value.generated = yes tok = ['{', value, token[2]] diff --git a/test/test_literals.coffee b/test/test_literals.coffee index 8b4373ac..1372eca1 100644 --- a/test/test_literals.coffee +++ b/test/test_literals.coffee @@ -216,6 +216,8 @@ eq '\\`', ` # Shorthand objects with property references. obj = + ### comment one ### + ### comment two ### one: 1 two: 2 object: -> {@one, @two}