From a5b7b2080623e744e9998b1bc55551a221e5c07c 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/issue753.txt | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/specs/issues/issue753.txt diff --git a/tests/specs/issues/issue753.txt b/tests/specs/issues/issue753.txt new file mode 100644 index 00000000..926e6394 --- /dev/null +++ b/tests/specs/issues/issue753.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 7ad13542c7d747f32d2540b2000f3844a301d0b9 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 2/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 f978a04b..dadb6274 100644 --- a/src/generation/generate.rs +++ b/src/generation/generate.rs @@ -9793,8 +9793,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(_) From fc1269f54b412512adc06953a7577b0a2622396d Mon Sep 17 00:00:00 2001 From: Adrian Gierakowski Date: Thu, 20 Nov 2025 12:36:19 +0100 Subject: [PATCH 3/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..46d53cad --- /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, + }); + };