Merge pull request #1542 from amasad/already-printed

Fix bug with paren printing in compact + line retained mode
This commit is contained in:
Sebastian McKenzie 2015-05-15 17:38:40 +01:00
commit 6f83111c55
4 changed files with 18 additions and 3 deletions

View File

@ -149,11 +149,12 @@ class CodeGenerator {
return print;
}
catchUp(node, parent) {
catchUp(node, parent, leftParenPrinted) {
// catch up to this nodes newline if we're behind
if (node.loc && this.format.retainLines && this.buffer.buf) {
var needsParens = false;
if (parent && this.position.line < node.loc.start.line && t.isTerminatorless(parent)) {
if (!leftParenPrinted && parent &&
this.position.line < node.loc.start.line && t.isTerminatorless(parent)) {
needsParens = true;
this._push("(");
}
@ -216,7 +217,7 @@ class CodeGenerator {
this.printLeadingComments(node, parent);
var needsParensFromCatchup = this.catchUp(node, parent);
var needsParensFromCatchup = this.catchUp(node, parent, needsParens);
newline(true);

View File

@ -0,0 +1,6 @@
function foo(l) {
return (
// hi
l
);
}

View File

@ -0,0 +1,4 @@
function foo(l){
return (
l);}

View File

@ -0,0 +1,4 @@
{
"retainLines": true,
"compact": true
}