ignore variable declarations inside loop head in newline generation - fixes #519

This commit is contained in:
Sebastian McKenzie
2015-01-17 17:44:16 +11:00
parent 1f9ce96e43
commit 4ec701fc44

View File

@@ -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 += " ";