From c8f0f52b4449364c75530954efd306228450fc40 Mon Sep 17 00:00:00 2001 From: nojaf Date: Sun, 4 Apr 2021 14:15:16 +0200 Subject: [PATCH] Print trivia for SynExpr.Paren in alternate style. Fixes #1276. --- src/Fantomas.Tests/AppTests.fs | 46 ++++++++++++++++++++++++++++++++++ src/Fantomas/CodePrinter.fs | 1 + 2 files changed, 47 insertions(+) diff --git a/src/Fantomas.Tests/AppTests.fs b/src/Fantomas.Tests/AppTests.fs index a9ed4c9823..61851843a4 100644 --- a/src/Fantomas.Tests/AppTests.fs +++ b/src/Fantomas.Tests/AppTests.fs @@ -580,3 +580,49 @@ module SomeModule = initialAbs / 100 """ + +[] +let ``comment after app with single tuple arg, 1276`` () = + formatSourceString + false + """ +SomeFunction(arg1, + arg2, + arg3) // does something +SomeOtherFunction(arg1, arg2) // does another thing +""" + config + |> prepend newline + |> should + equal + """ +SomeFunction(arg1, arg2, arg3) // does something +SomeOtherFunction(arg1, arg2) // does another thing +""" + +[] +let ``comment after app with single tuple arg, multiline format`` () = + formatSourceString + false + """ +SomeFunction(arg1, + arg2, + arg3) // does something +SomeOtherFunction(arg1, arg2) // does another thing +""" + { config with MaxLineLength = 20 } + |> prepend newline + |> should + equal + """ +SomeFunction( + arg1, + arg2, + arg3 +) // does something + +SomeOtherFunction( + arg1, + arg2 +) // does another thing +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 43b2737c8e..665920c835 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2849,6 +2849,7 @@ and genMultilineFunctionApplicationArguments sepOpenTFor sepCloseTFor astContext +> unindent +> sepNln +> sepCloseTFor rpr pr + |> genTriviaFor SynExpr_Paren pr let genExpr astContext e = match e with