Skip to content

Commit

Permalink
Fixes command breaking with lambda in tuple, #2771
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Feb 18, 2023
1 parent 9f769d8 commit d210e84
Show file tree
Hide file tree
Showing 3 changed files with 33 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

## [Unreleased]

### 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
24 changes: 24 additions & 0 deletions src/Fantomas.Core.Tests/TupleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,27 @@ 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 with
MaxIfThenElseShortWidth = 40 }
|> 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 d210e84

Please sign in to comment.