Skip to content

Commit

Permalink
Print trivia for MatchLambda in multiline infix expression. (#2456)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Aug 29, 2022
1 parent bda3daa commit 3ce0391
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Idempotency problem when using a list with interpolated strings. [#2242](https://github.com/fsprojects/fantomas/issues/2242)
* Idempotency problem when using set and spread syntax. [#2392](https://github.com/fsprojects/fantomas/issues/2392)
* Formatting (*) returns ( * ). [#2452](https://github.com/fsprojects/fantomas/issues/2452)
* Comment after last case of function with operator is removed.[#2454](https://github.com/fsprojects/fantomas/issues/2454)

## [5.0.0-beta-007] - 2022-08-19

Expand Down
23 changes: 23 additions & 0 deletions src/Fantomas.Core.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,3 +1430,26 @@ let (*) x y = x + y
"""
let (*) x y = x + y
"""
[<Test>]
let ``trivia after match lambda in infix operation, 2454`` () =
formatSourceString
false
"""
id
>> function
| -1 -> -1 // first comment
| 0 -> 0 // second comment
| _ -> 1 // third comment
"""
config
|> prepend newline
|> should
equal
"""
id
>> function
| -1 -> -1 // first comment
| 0 -> 0 // second comment
| _ -> 1 // third comment
"""
1 change: 1 addition & 0 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,7 @@ and genExprInMultilineInfixExpr astContext e =
| MatchLambda (keywordRange, cs) ->
(!- "function " |> genTriviaFor SynExpr_MatchLambda_Function keywordRange)
+> indentSepNlnUnindent (genClauses astContext cs)
|> genTriviaFor SynExpr_MatchLambda e.Range
| Record _ -> atCurrentColumnIndent (genExpr astContext e)
| _ -> genExpr astContext e

Expand Down

0 comments on commit 3ce0391

Please sign in to comment.