Skip to content

Commit a7ed99f

Browse files
authored
Merge pull request #2776 from TheAngryByrd/2771-comma-breaks-code
Fixes command breaking with lambda in tuple, #2771
2 parents 9f769d8 + 9b90b56 commit a7ed99f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [5.2.2] - 2023-02-18
4+
5+
### Fixed
6+
* Fixes comma breaking with lambda in tuple. [#2771](https://github.com/fsprojects/fantomas/issues/2771)
7+
38
## [5.2.1] - 2023-02-04
49

510
### Fixed

src/Fantomas.Core.Tests/TupleTests.fs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,26 @@ let f x =
397397
398398
()
399399
"""
400+
401+
[<Test>]
402+
let ``comma should not break with lambda as tuple, 2771`` () =
403+
formatSourceString
404+
false
405+
"""
406+
let shiftTimes localDate (start: Utc, duration) =
407+
ZonedDate.create TimeZone.current localDate
408+
|> Time.ZonedDate.startOf
409+
|> fun dayStart -> start + dayStart.Duration - refDay.StartTime.Duration
410+
, duration
411+
"""
412+
config
413+
|> prepend newline
414+
|> should
415+
equal
416+
"""
417+
let shiftTimes localDate (start: Utc, duration) =
418+
ZonedDate.create TimeZone.current localDate
419+
|> Time.ZonedDate.startOf
420+
|> fun dayStart -> start + dayStart.Duration - refDay.StartTime.Duration
421+
, duration
422+
"""

src/Fantomas.Core/CodePrinter.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,10 @@ let genTupleMultiline (node: ExprTupleNode) =
17541754
match node.RightHandSide with
17551755
| Expr.Lambda _ -> true
17561756
| _ -> false
1757+
| Expr.SameInfixApps node ->
1758+
match List.last node.SubsequentExpressions with
1759+
| _, Expr.Lambda _ -> true
1760+
| _ -> false
17571761
| _ -> false
17581762
| _ -> false)
17591763

0 commit comments

Comments
 (0)