Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created April 21, 2010 09:27
Show Gist options
  • Save StanAngeloff/373618 to your computer and use it in GitHub Desktop.
Save StanAngeloff/373618 to your computer and use it in GitHub Desktop.
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