From e13a449f3abdfca7c061c94a07258a7c1079689e Mon Sep 17 00:00:00 2001 From: Adrian Gierakowski Date: Thu, 20 Nov 2025 09:04:15 +0100 Subject: [PATCH 1/3] tests: add for case for issue: 753 --- tests/specs/issues/issue0753.txt | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/specs/issues/issue0753.txt diff --git a/tests/specs/issues/issue0753.txt b/tests/specs/issues/issue0753.txt new file mode 100644 index 00000000..1192c375 --- /dev/null +++ b/tests/specs/issues/issue0753.txt @@ -0,0 +1,46 @@ +~~ lineWidth: 80, indentWidth: 2, memberExpression.linePerExpression: true ~~ +== function args == +const startingFrom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day")) + +const func = () => + function() { + const startingFrom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day")) + } + + +[expect] +const startingFrom = Mylib.map( + DateTime.now, + now => DateTime.startOf(now, "day"), +); + +const func = () => + function() { + const startingFrom = Mylib.map( + DateTime.now, + now => DateTime.startOf(now, "day"), + ); + }; + +== function args same line length == +const startingFroom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day")) + +const func = () => + function() { + const startingF = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day")) + } + + +[expect] +const startingFroom = Mylib.map( + DateTime.now, + now => DateTime.startOf(now, "day"), +); + +const func = () => + function() { + const startingF = Mylib.map( + DateTime.now, + now => DateTime.startOf(now, "day"), + ); + }; From 69cdb5e1ab797bab1b2c180f2e8760475c986976 Mon Sep 17 00:00:00 2001 From: Adrian Gierakowski Date: Thu, 20 Nov 2025 12:36:19 +0100 Subject: [PATCH 2/3] tests: add for case for issue: 686 --- tests/specs/issues/issue0686.txt | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/specs/issues/issue0686.txt diff --git a/tests/specs/issues/issue0686.txt b/tests/specs/issues/issue0686.txt new file mode 100644 index 00000000..08f7d6a7 --- /dev/null +++ b/tests/specs/issues/issue0686.txt @@ -0,0 +1,45 @@ +~~ lineWidth: 80, indentWidth: 2, memberExpression.linePerExpression: true ~~ +== generator == +const createTestData = () => + function*() { + const startingFrom = yield* Effect.map(DateTime.now, now => DateTime.startOf(now, "day")) + + return HashSet.make(DateTime.toEpochMillis(startingFrom)) + }; + + +[expect] +const createTestData = () => + function*() { + const startingFrom = yield* Effect.map( + DateTime.now, + now => DateTime.startOf(now, "day"), + ); + + return HashSet.make(DateTime.toEpochMillis(startingFrom)); + }; + +== function == +const func = () => + function() { + const startingFrom = Effect.map(DateTime.now, now => DateTime.startOf(now, 'day')) + + return myObj + .myMethod({ + missionType: otherObj.prop.nested, + }); + }; + +[expect] +const func = () => + function() { + const startingFrom = Effect.map( + DateTime.now, + now => DateTime.startOf(now, "day"), + ); + + return myObj + .myMethod({ + missionType: otherObj.prop.nested, + }); + }; From fa7e5905908048fc1378c8b10739665f45fd4b30 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 20 Nov 2025 10:33:08 +0000 Subject: [PATCH 3/3] fix: improve formatting of arrow functions as arguments This change modifies `allows_inline_multi_line` to restrict arrow functions with expression bodies from being inline multi-line. This ensures that if such an arrow function overflows the line width, it forces the parent call expression to break its arguments onto multiple lines, rather than allowing a partial split that results in inconsistent formatting. Fixes #753 Fixes #686 --- src/generation/generate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generation/generate.rs b/src/generation/generate.rs index 5c5ad077..e9da6d58 100644 --- a/src/generation/generate.rs +++ b/src/generation/generate.rs @@ -9811,8 +9811,8 @@ fn allows_inline_multi_line<'a>(node: Node<'a>, context: &Context<'a>, has_sibli _ => allows_inline_multi_line(as_expr.type_ann.into(), context, has_siblings), } } + Node::ArrowExpr(arrow) => matches!(arrow.body, BlockStmtOrExpr::BlockStmt(_)), Node::FnExpr(_) - | Node::ArrowExpr(_) | Node::ObjectLit(_) | Node::ArrayLit(_) | Node::ObjectPat(_)