avoid printing comments if they've already been output - fixes #365

This commit is contained in:
Sebastian McKenzie
2015-01-02 22:22:01 +11:00
parent d981c06444
commit 339bf82481
2 changed files with 11 additions and 0 deletions

View File

@@ -274,14 +274,21 @@ CodeGenerator.prototype._printComments = function (comments) {
var self = this;
_.each(comments, function (comment) {
var skip = false;
// find the original comment in the ast and set it as displayed
_.each(self.ast.comments, function (origComment) {
if (origComment.start === comment.start) {
// comment has already been output
if (origComment._displayed) skip = true;
origComment._displayed = true;
return false;
}
});
if (skip) return;
// whitespace before
self.newline(self.whitespace.getNewlinesBefore(comment));