Skip to content

Commit 4a37a90

Browse files
committed
always print function expressions on a new line to make sure the outer code accepts breakpoints
1 parent 8dfcc37 commit 4a37a90

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "its-typescript-to-lua",
3-
"version": "1.33.2-6",
3+
"version": "1.33.2-7",
44
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
55
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
66
"homepage": "https://typescripttolua.github.io/",

src/LuaAST.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,7 @@ export function isInlineFunctionExpression(expression: FunctionExpression): expr
855855
expression.body.statements?.length === 1 &&
856856
isReturnStatement(expression.body.statements[0]) &&
857857
expression.body.statements[0].expressions !== undefined &&
858-
(expression.flags & NodeFlags.Inline) !== 0 &&
859-
false
858+
(expression.flags & NodeFlags.Inline) !== 0
860859
);
861860
}
862861

src/LuaPrinter.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -664,26 +664,27 @@ export class LuaPrinter {
664664
public printFunctionExpression(expression: lua.FunctionExpression): SourceNode {
665665
const chunks: SourceChunk[] = [];
666666

667+
chunks.push("\n");
667668
chunks.push("function(");
668669
chunks.push(...this.printFunctionParameters(expression));
669670
chunks.push(")");
670671

671-
if (lua.isInlineFunctionExpression(expression)) {
672-
const returnStatement = expression.body.statements[0];
673-
chunks.push(" ");
674-
const returnNode: SourceChunk[] = [
675-
"return ",
676-
...this.joinChunksWithComma(returnStatement.expressions.map(e => this.printExpression(e))),
677-
];
678-
chunks.push(this.createSourceNode(returnStatement, returnNode));
679-
chunks.push(this.createSourceNode(expression, " end"));
680-
} else {
681-
chunks.push("\n");
682-
this.pushIndent();
683-
chunks.push(this.printBlock(expression.body));
684-
this.popIndent();
685-
chunks.push(this.indent(this.createSourceNode(expression, "end")));
686-
}
672+
// if (lua.isInlineFunctionExpression(expression)) {
673+
// const returnStatement = expression.body.statements[0];
674+
// chunks.push(" ");
675+
// const returnNode: SourceChunk[] = [
676+
// "return ",
677+
// ...this.joinChunksWithComma(returnStatement.expressions.map(e => this.printExpression(e))),
678+
// ];
679+
// chunks.push(this.createSourceNode(returnStatement, returnNode));
680+
// chunks.push(this.createSourceNode(expression, " end"));
681+
// } else {
682+
chunks.push("\n");
683+
this.pushIndent();
684+
chunks.push(this.printBlock(expression.body));
685+
this.popIndent();
686+
chunks.push(this.indent(this.createSourceNode(expression, "end")));
687+
// }
687688

688689
return this.createSourceNode(expression, chunks);
689690
}

0 commit comments

Comments
 (0)