From 194afb2c485deab3a9ae4c9bff1bccbe1cdba9cc Mon Sep 17 00:00:00 2001 From: Asmus Bartram Date: Sat, 14 Sep 2024 10:15:07 +0200 Subject: [PATCH 1/5] Check if we just wrote a DotLambda on a record value before deciding on space before parens, fix 3120 --- src/Fantomas.Core.Tests/DotLambdaTests.fs | 15 +++++++++++++++ src/Fantomas.Core/CodePrinter.fs | 1 + 2 files changed, 16 insertions(+) diff --git a/src/Fantomas.Core.Tests/DotLambdaTests.fs b/src/Fantomas.Core.Tests/DotLambdaTests.fs index 4e8abdb60..83d9ecabe 100644 --- a/src/Fantomas.Core.Tests/DotLambdaTests.fs +++ b/src/Fantomas.Core.Tests/DotLambdaTests.fs @@ -75,6 +75,21 @@ let ``idempotency problem when _.Property shorthand, 3050`` () = "ABC" |> _.ToLower() """ +[] +let ``idempotency problem with _.Property shorthand with record value,`` () = + formatSourceString + """ +_.A.ToLower() +""" + { config with + SpaceBeforeUppercaseInvocation = true } + |> prepend newline + |> should + equal + """ +_.A.ToLower() +""" + [] let ``idempotency problem when _.property shorthand lowercase, 3050`` () = formatSourceString diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index 6e68cf381..18e80902b 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -1572,6 +1572,7 @@ let genExpr (e: Expr) = let genDotLambdaExpr expr = match expr with | Expr.AppSingleParenArg p -> genAppSingleParenArgExpr sepNone p // be always atomic, see 3050 + | Expr.AppLongIdentAndSingleParenArg p -> genAppLongIdentAndSingleParenArgExpr sepNone p | _ -> genExpr expr genSingleTextNode node.Underscore From bbcf41f4543621ed93f4b4c5d6290a99da788e0b Mon Sep 17 00:00:00 2001 From: Asmus Bartram Date: Sat, 14 Sep 2024 10:17:31 +0200 Subject: [PATCH 2/5] Add note about referring to issue --- 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 18e80902b..bb2c91018 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -1572,7 +1572,7 @@ let genExpr (e: Expr) = let genDotLambdaExpr expr = match expr with | Expr.AppSingleParenArg p -> genAppSingleParenArgExpr sepNone p // be always atomic, see 3050 - | Expr.AppLongIdentAndSingleParenArg p -> genAppLongIdentAndSingleParenArgExpr sepNone p + | Expr.AppLongIdentAndSingleParenArg p -> genAppLongIdentAndSingleParenArgExpr sepNone p // see 3120 | _ -> genExpr expr genSingleTextNode node.Underscore From 6f97de5b4062d3e4e198833d9c60165df2193346 Mon Sep 17 00:00:00 2001 From: Asmus Bartram Date: Sat, 14 Sep 2024 10:28:21 +0200 Subject: [PATCH 3/5] add changelog entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc1f31bd6..a8520eda4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [Unreleased] + +### Fixed +* Idempotency problem when _.Property shorthand with record value. [#3120](https://github.com/fsprojects/fantomas/issues/3120) + ## 6.3.13 - 2024-09-10 ### Fixed From b3f38b2f50c140a04f07e7a62f959842e5c1cd23 Mon Sep 17 00:00:00 2001 From: Asmus Bartram Date: Sat, 14 Sep 2024 10:49:16 +0200 Subject: [PATCH 4/5] Reference issue id in test name Co-authored-by: dawe --- src/Fantomas.Core.Tests/DotLambdaTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fantomas.Core.Tests/DotLambdaTests.fs b/src/Fantomas.Core.Tests/DotLambdaTests.fs index 83d9ecabe..67c001b82 100644 --- a/src/Fantomas.Core.Tests/DotLambdaTests.fs +++ b/src/Fantomas.Core.Tests/DotLambdaTests.fs @@ -76,7 +76,7 @@ let ``idempotency problem when _.Property shorthand, 3050`` () = """ [] -let ``idempotency problem with _.Property shorthand with record value,`` () = +let ``idempotency problem with _.Property shorthand with record value, 3120`` () = formatSourceString """ _.A.ToLower() From a9a0e51757ce8e7a8bb935fec1eab05109cb9501 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Sat, 14 Sep 2024 13:46:50 +0200 Subject: [PATCH 5/5] Bump version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8520eda4..0a6b1e82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## 6.3.14 - 2024-09-14 ### Fixed * Idempotency problem when _.Property shorthand with record value. [#3120](https://github.com/fsprojects/fantomas/issues/3120)