From be5d577c2dda90cc661fe819f91b7a824cd5a931 Mon Sep 17 00:00:00 2001 From: Asmus Bartram Date: Sat, 14 Sep 2024 13:55:48 +0200 Subject: [PATCH] Check if we just wrote a DotLambda on a record value before deciding on space before parens, fix 3120 (#3121) * Check if we just wrote a DotLambda on a record value before deciding on space before parens, fix 3120 * Add note about referring to issue * add changelog entry * Reference issue id in test name Co-authored-by: dawe * Bump version --------- Co-authored-by: dawe Co-authored-by: Florian Verdonck --- CHANGELOG.md | 5 +++++ src/Fantomas.Core.Tests/DotLambdaTests.fs | 15 +++++++++++++++ src/Fantomas.Core/CodePrinter.fs | 1 + 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc1f31bd6..0a6b1e82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 6.3.14 - 2024-09-14 + +### Fixed +* Idempotency problem when _.Property shorthand with record value. [#3120](https://github.com/fsprojects/fantomas/issues/3120) + ## 6.3.13 - 2024-09-10 ### Fixed diff --git a/src/Fantomas.Core.Tests/DotLambdaTests.fs b/src/Fantomas.Core.Tests/DotLambdaTests.fs index 4e8abdb60..67c001b82 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, 3120`` () = + 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..bb2c91018 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 // see 3120 | _ -> genExpr expr genSingleTextNode node.Underscore