Created
April 21, 2010 09:27
-
-
Save StanAngeloff/373618 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/rewriter.coffee b/src/rewriter.coffee | |
index ec07bd4..6210088 100644 | |
--- a/src/rewriter.coffee | |
+++ b/src/rewriter.coffee | |
@@ -54,10 +54,14 @@ exports.Rewriter: class Rewriter | |
adjust_comments: -> | |
@scan_tokens (prev, token, post, i) => | |
return 1 unless token[0] is 'COMMENT' | |
+ before: @tokens[i - 2] | |
after: @tokens[i + 2] | |
if after and after[0] is 'INDENT' | |
@tokens.splice i + 2, 1 | |
- @tokens.splice i, 0, after | |
+ if before and before[0] is 'OUTDENT' and prev and prev[0] is 'TERMINATOR' and post and post[0] is 'TERMINATOR' | |
+ @tokens.splice i - 2, 1 | |
+ else | |
+ @tokens.splice i, 0, after | |
return 1 | |
else if prev and prev[0] isnt 'TERMINATOR' and prev[0] isnt 'INDENT' and prev[0] isnt 'OUTDENT' | |
@tokens.splice i, 0, ['TERMINATOR', "\n", prev[2]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment