Skip to content

Commit

Permalink
Print trivia before SynExpr.MatchLambda. Fix #1074 (#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 3, 2020
1 parent cd98ed3 commit 62d9a0d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,30 @@ let private update onSubmit msg model =
Map.remove "distance" model.Errors
{ model with Errors = errors }, Cmd.none
"""
"""

[<Test>]
let ``keep new line before function match, 1074`` () =
formatSourceString false """
let (|AndExpr|_|) =
let chooser =
function
| (ExprPat e1, ExprPat e2) -> Some(e1, e2)
| _ -> None
function
| ListSplitPick "&&" chooser (e1, e2) -> Some(BoolExpr.And(e1, e2))
| _ -> None
""" config
|> prepend newline
|> should equal """
let (|AndExpr|_|) =
let chooser =
function
| (ExprPat e1, ExprPat e2) -> Some(e1, e2)
| _ -> None
function
| ListSplitPick "&&" chooser (e1, e2) -> Some(BoolExpr.And(e1, e2))
| _ -> None
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,7 @@ and genExpr astContext synExpr =
| SynExpr.New _ -> genTriviaFor SynExpr_New synExpr.Range
| SynExpr.Assert _ -> genTriviaFor SynExpr_Assert synExpr.Range
| SynExpr.While _ -> genTriviaFor SynExpr_While synExpr.Range
| SynExpr.MatchLambda _ -> genTriviaFor SynExpr_MatchLambda synExpr.Range
| _ -> id)

and genMultilineRecordInstance
Expand Down

0 comments on commit 62d9a0d

Please sign in to comment.