From b03be8310dde4ca0da727df73131bf6b70cd2e2a Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 12 Jul 2024 11:11:55 +0200 Subject: [PATCH 1/3] add test for 3097 --- src/Fantomas.Core.Tests/DotLambdaTests.fs | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Fantomas.Core.Tests/DotLambdaTests.fs b/src/Fantomas.Core.Tests/DotLambdaTests.fs index 45285c3e3..4e8abdb60 100644 --- a/src/Fantomas.Core.Tests/DotLambdaTests.fs +++ b/src/Fantomas.Core.Tests/DotLambdaTests.fs @@ -131,3 +131,31 @@ type Bar() = let b = Bar () b |> _.Foo(Meh ()) """ + +[] +let ``regression with dot lambda args being pushed out too far, 3097`` () = + formatSourceString + """ +workstations +|> Seq.sumBy + _.GetWeeklyValueWithoutAccessCheck( + year, + week, + CapacityAggregateValueType.CostPrice, + category + ) +""" + { config with MaxLineLength = 50 } + |> prepend newline + |> should + equal + """ +workstations +|> Seq.sumBy + _.GetWeeklyValueWithoutAccessCheck( + year, + week, + CapacityAggregateValueType.CostPrice, + category + ) +""" From bf5a6e1515ef22bfb804cf260d81135a017b44ee Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 12 Jul 2024 11:12:31 +0200 Subject: [PATCH 2/3] call genAppSingleParenArgExpr with sepNone to be atomic but also keep old behaviour --- src/Fantomas.Core/CodePrinter.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index 38ba58c8c..f1b58cbda 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -1562,7 +1562,7 @@ let genExpr (e: Expr) = | Expr.DotLambda node -> let genDotLambdaExpr expr = match expr with - | Expr.AppSingleParenArg p -> genExpr p.FunctionExpr +> genExpr p.ArgExpr // be always atomic, see 3050 + | Expr.AppSingleParenArg p -> genAppSingleParenArgExpr sepNone p // be always atomic, see 3050 | _ -> genExpr expr genSingleTextNode node.Underscore From 60fc9902f80e2659c0d2579537e638e20b2f52a4 Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 12 Jul 2024 11:12:42 +0200 Subject: [PATCH 3/3] add changelog entry --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 534673a5f..891db0e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ # Changelog -## [Unreleased] +## 6.3.10 - 2024-07-12 ### Changed * Update FCS to 'Allow ParsedHashDirectives to take non string arguments', commit 836d4e0603442d6053c8d439993a022501cae494 [#3096](https://github.com/fsprojects/fantomas/pull/3096) +### Fixed +* Regression with dot lambda args being pushed out too far. [#3097](https://github.com/fsprojects/fantomas/issues/3097) + ## 6.3.9 - 2024-06-10 ### Fixed