Use .append to force-commit semicolons for empty statements.

This commit is contained in:
Logan Smyth 2016-07-14 22:07:40 -07:00
parent bd9bb053c3
commit 1bf76b0f33
2 changed files with 4 additions and 7 deletions

View File

@ -137,8 +137,7 @@ export let YieldExpression = buildYieldAwait("yield");
export let AwaitExpression = buildYieldAwait("await"); export let AwaitExpression = buildYieldAwait("await");
export function EmptyStatement() { export function EmptyStatement() {
this._lastPrintedIsEmptyStatement = true; this.semicolon(true /* force */);
this.semicolon();
} }
export function ExpressionStatement(node: Object) { export function ExpressionStatement(node: Object) {

View File

@ -53,8 +53,8 @@ export default class Printer {
* Add a semicolon to the buffer. * Add a semicolon to the buffer.
*/ */
semicolon(): void { semicolon(force: boolean = false): void {
this._append(";", true /* queue */); this._append(";", !force /* queue */);
} }
/** /**
@ -64,7 +64,7 @@ export default class Printer {
rightBrace(): void { rightBrace(): void {
if (!this.endsWith("\n")) this.newline(); if (!this.endsWith("\n")) this.newline();
if (this.format.minified && !this._lastPrintedIsEmptyStatement) { if (this.format.minified) {
this._buf.removeLastSemicolon(); this._buf.removeLastSemicolon();
} }
this.token("}"); this.token("}");
@ -262,8 +262,6 @@ export default class Printer {
print(node, parent, opts = {}) { print(node, parent, opts = {}) {
if (!node) return; if (!node) return;
this._lastPrintedIsEmptyStatement = false;
if (parent && parent._compact) { if (parent && parent._compact) {
node._compact = true; node._compact = true;
} }