fix retainLines for comments and block statements - fixes #1388

This commit is contained in:
Sebastian McKenzie
2015-04-30 17:43:31 +01:00
parent 1066a42fb2
commit 98206df864
2 changed files with 7 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ export function BlockStatement(node, print) {
this.push("{");
this.newline();
print.sequence(node.body, { indent: true });
this.removeLast("\n");
if (!this.format.retainLines) this.removeLast("\n");
this.rightBrace();
}
}

View File

@@ -376,6 +376,12 @@ class CodeGenerator {
val = this.getIndent() + val;
}
// force a newline for line comments when retainLines is set in case the next printed node
// doesn't catch up
if (this.format.retainLines && comment.type === "Line") {
val += "\n";
}
//
this._push(val);