ignore variable declarations inside loop head in newline generation - fixes #519
This commit is contained in:
@@ -169,16 +169,18 @@ exports.VariableDeclaration = function (node, print, parent) {
|
||||
|
||||
var inits = 0;
|
||||
var noInits = 0;
|
||||
for (var i = 0; i < node.declarations.length; i++) {
|
||||
if (node.declarations[i].init) {
|
||||
inits++;
|
||||
} else {
|
||||
noInits++;
|
||||
if (!t.isFor(parent)) {
|
||||
for (var i = 0; i < node.declarations.length; i++) {
|
||||
if (node.declarations[i].init) {
|
||||
inits++;
|
||||
} else {
|
||||
noInits++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sep = ",";
|
||||
if (inits > noInits) { // more inits than noinits
|
||||
if (inits > noInits) { // more inits than no inits so let's add a newline
|
||||
sep += "\n" + util.repeat(node.kind.length + 1);
|
||||
} else {
|
||||
sep += " ";
|
||||
|
||||
Reference in New Issue
Block a user