From 5a393d1961f56ae9803493f472ed4fd275d452c7 Mon Sep 17 00:00:00 2001 From: ijanus Date: Wed, 9 Feb 2022 15:25:26 +0100 Subject: [PATCH] Always add a space for multiple curried args invocation Addresses https://github.com/dotnet/docs/pull/28141 --- src/Fantomas.Tests/SingleExprTests.fs | 19 +++++++++++++++++++ src/Fantomas/CodePrinter.fs | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/Fantomas.Tests/SingleExprTests.fs b/src/Fantomas.Tests/SingleExprTests.fs index 7fc8913e52..a10bda4e92 100644 --- a/src/Fantomas.Tests/SingleExprTests.fs +++ b/src/Fantomas.Tests/SingleExprTests.fs @@ -213,3 +213,22 @@ let ``comment after address of tokens`` () = && // comment foobar """ + +[] +let ``function invocation with multiple curried parameters`` () = + formatSourceString + false + """ +module Foo = + let Bar (baz1: int) (baz2: string) (baz3: string) (baz4: string) = + FooBarBaz(someFunc x) (someOtherFunc y) +""" + config + |> prepend newline + |> should + equal + """ +module Foo = + let Bar (baz1: int) (baz2: string) (baz3: string) (baz4: string) = + FooBarBaz (someFunc x) (someOtherFunc y) +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index d29b8a8197..0927f6e71b 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -3215,6 +3215,10 @@ and genApp astContext e es ctx = (fun ctx -> match es with | [] -> false + | Paren _ :: rest when es.Length > 1 -> + match rest with + | Paren _ :: _ -> true + | _ -> addSpaceBeforeParensInFunCall e es.Head ctx | [ h ] | h :: _ -> addSpaceBeforeParensInFunCall e h ctx) sepSpace