Skip to content

Commit

Permalink
Merge pull request #2776 from TheAngryByrd/2771-comma-breaks-code
Browse files Browse the repository at this point in the history
Fixes command breaking with lambda in tuple, #2771
  • Loading branch information
josh-degraw authored Feb 21, 2023
2 parents 9f769d8 + 9b90b56 commit a7ed99f
Show file tree
Hide file tree
Showing 3 changed files with 32 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

## [5.2.2] - 2023-02-18

### Fixed
* Fixes comma breaking with lambda in tuple. [#2771](https://github.com/fsprojects/fantomas/issues/2771)

## [5.2.1] - 2023-02-04

### Fixed
Expand Down
23 changes: 23 additions & 0 deletions src/Fantomas.Core.Tests/TupleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,26 @@ let f x =
()
"""

[<Test>]
let ``comma should not break with lambda as tuple, 2771`` () =
formatSourceString
false
"""
let shiftTimes localDate (start: Utc, duration) =
ZonedDate.create TimeZone.current localDate
|> Time.ZonedDate.startOf
|> fun dayStart -> start + dayStart.Duration - refDay.StartTime.Duration
, duration
"""
config
|> prepend newline
|> should
equal
"""
let shiftTimes localDate (start: Utc, duration) =
ZonedDate.create TimeZone.current localDate
|> Time.ZonedDate.startOf
|> fun dayStart -> start + dayStart.Duration - refDay.StartTime.Duration
, duration
"""
4 changes: 4 additions & 0 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,10 @@ let genTupleMultiline (node: ExprTupleNode) =
match node.RightHandSide with
| Expr.Lambda _ -> true
| _ -> false
| Expr.SameInfixApps node ->
match List.last node.SubsequentExpressions with
| _, Expr.Lambda _ -> true
| _ -> false
| _ -> false
| _ -> false)

Expand Down

0 comments on commit a7ed99f

Please sign in to comment.