Skip to content

Commit

Permalink
Check if we just wrote a DotLambda on a record value before deciding …
Browse files Browse the repository at this point in the history
…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 <[email protected]>

* Bump version

---------

Co-authored-by: dawe <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
  • Loading branch information
3 people authored Sep 14, 2024
1 parent ceb1fa2 commit be5d577
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/Fantomas.Core.Tests/DotLambdaTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ let ``idempotency problem when _.Property shorthand, 3050`` () =
"ABC" |> _.ToLower()
"""

[<Test>]
let ``idempotency problem with _.Property shorthand with record value, 3120`` () =
formatSourceString
"""
_.A.ToLower()
"""
{ config with
SpaceBeforeUppercaseInvocation = true }
|> prepend newline
|> should
equal
"""
_.A.ToLower()
"""

[<Test>]
let ``idempotency problem when _.property shorthand lowercase, 3050`` () =
formatSourceString
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be5d577

Please sign in to comment.