Merge pull request #3104 from amasad/semi
Fix up semicolon omission in compact mode
This commit is contained in:
commit
8457885599
@ -101,7 +101,9 @@ export default class Buffer {
|
|||||||
|
|
||||||
rightBrace() {
|
rightBrace() {
|
||||||
this.newline(true);
|
this.newline(true);
|
||||||
//if (this.format.compact) this._removeLast(";");
|
if (this.format.compact && !this._lastPrintedIsEmptyStatement) {
|
||||||
|
this._removeLast(";");
|
||||||
|
}
|
||||||
this.push("}");
|
this.push("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -130,6 +130,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();
|
this.semicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,8 @@ export default class Printer extends Buffer {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -144,12 +146,11 @@ export default class Printer extends Buffer {
|
|||||||
|
|
||||||
printBlock(parent) {
|
printBlock(parent) {
|
||||||
let node = parent.body;
|
let node = parent.body;
|
||||||
if (t.isEmptyStatement(node)) {
|
if (!t.isEmptyStatement(node)) {
|
||||||
this.semicolon();
|
this.space();
|
||||||
} else {
|
|
||||||
this.push(" ");
|
|
||||||
this.print(node, parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.print(node, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateComment(comment) {
|
generateComment(comment) {
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
function foo() {
|
function foo() {
|
||||||
|
var x = 1;
|
||||||
|
y();
|
||||||
if (bar) {
|
if (bar) {
|
||||||
baz();
|
baz();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bar() {
|
||||||
|
for(;;);
|
||||||
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
function foo(){if(bar){baz();}return;}
|
function foo(){var x=1;y();if(bar){baz()}return}function bar(){for(;;);}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
function foo(l){
|
function foo(l){
|
||||||
return (
|
return (
|
||||||
|
|
||||||
l);}
|
l)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user