Merge pull request #1542 from amasad/already-printed
Fix bug with paren printing in compact + line retained mode
This commit is contained in:
commit
6f83111c55
@ -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);
|
||||
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
function foo(l) {
|
||||
return (
|
||||
// hi
|
||||
l
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
function foo(l){
|
||||
return (
|
||||
|
||||
l);}
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"retainLines": true,
|
||||
"compact": true
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user