Skip to content

Commit

Permalink
Don't add a newline if there are no additional arguments before lambd…
Browse files Browse the repository at this point in the history
…a. (#1923)

Fixes #1922.
  • Loading branch information
nojaf committed Jan 8, 2022
1 parent 87bb8a5 commit 857d455
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/Fantomas.Tests/LambdaTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,3 +1069,26 @@ leadingExpressionIsMultiline
| Ok _ -> true
| Error _ -> false)
"""

[<Test>]
let ``multiline lambda argument, 1922`` () =
formatSourceString
false
"""
let g =
Array.groupBy
(fun { partNumber = p
revisionNumber = r
processName = pn } -> p, r, pn)
"""
config
|> prepend newline
|> should
equal
"""
let g =
Array.groupBy
(fun { partNumber = p
revisionNumber = r
processName = pn } -> p, r, pn)
"""
2 changes: 1 addition & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ and genExpr astContext synExpr ctx =
+> indent
+> sepNln
+> col sepNln es (genExpr astContext)
+> sepNln
+> onlyIfNot (List.isEmpty es) sepNln
+> (sepOpenTFor lpr
+> (!- "fun "
+> col sepSpace pats (genPat astContext)
Expand Down

0 comments on commit 857d455

Please sign in to comment.