Skip to content

Commit 216f0a3

Browse files
committed
expression list: always print on one line, except function calls on separate lines (for debugging)
1 parent c055cea commit 216f0a3

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/LuaPrinter.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -867,17 +867,23 @@ export class LuaPrinter {
867867
protected printExpressionList(expressions: lua.Expression[]): SourceChunk[] {
868868
const chunks: SourceChunk[] = [];
869869

870-
if (this.isSimpleExpressionList(expressions)) {
871-
chunks.push(...this.joinChunksWithComma(expressions.map(e => this.printExpression(e))));
872-
} else {
873-
chunks.push("\n");
874-
this.pushIndent();
875-
for (const [index, expression] of expressions.entries()) {
870+
for (const [index, expression] of expressions.entries()) {
871+
if (lua.isCallExpression(expression)) {
872+
if (index === 0) {
873+
chunks.push("\n");
874+
} else {
875+
chunks.pop();
876+
chunks.push(",\n");
877+
}
878+
this.pushIndent();
876879
const tail = index < expressions.length - 1 ? ",\n" : "\n";
877880
chunks.push(this.indent(), this.printExpression(expression), tail);
881+
this.popIndent();
882+
chunks.push(this.indent());
883+
} else {
884+
const tail = index < expressions.length - 1 ? ", " : "";
885+
chunks.push(this.printExpression(expression), tail);
878886
}
879-
this.popIndent();
880-
chunks.push(this.indent());
881887
}
882888

883889
return chunks;

0 commit comments

Comments
 (0)