From c419411afea9f11f5cec603badeb3ddaf6355c5e Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Fri, 22 Oct 2021 11:56:11 +0200 Subject: [PATCH] Don't add a newline if there are no additional arguments before lambda. (#1923) Fixes #1922. --- src/Fantomas.Tests/LambdaTests.fs | 23 +++++++++++++++++++++++ src/Fantomas/CodePrinter.fs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Fantomas.Tests/LambdaTests.fs b/src/Fantomas.Tests/LambdaTests.fs index f47fe6754a..5f96a03b4a 100644 --- a/src/Fantomas.Tests/LambdaTests.fs +++ b/src/Fantomas.Tests/LambdaTests.fs @@ -1069,3 +1069,26 @@ leadingExpressionIsMultiline | Ok _ -> true | Error _ -> false) """ + +[] +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) +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 1f65697564..9ae540eb14 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -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)