diff --git a/src/Fantomas.Tests/AppTests.fs b/src/Fantomas.Tests/AppTests.fs index 113fd23882..1933887c7f 100644 --- a/src/Fantomas.Tests/AppTests.fs +++ b/src/Fantomas.Tests/AppTests.fs @@ -877,3 +877,22 @@ let Ok (content: string) = ) #endif """ + +[] +let ``function invocation with multiple curried parameters, 2087`` () = + formatSourceString + false + """ +module Foo = + let Bar (baz1: int) (baz2: string) (baz3: string) (baz4: string) (baz5: string) = + FooBarBaz(someFunc x) (someOtherFunc y) +""" + config + |> prepend newline + |> should + equal + """ +module Foo = + let Bar (baz1: int) (baz2: string) (baz3: string) (baz4: string) (baz5: string) = + FooBarBaz (someFunc x) (someOtherFunc y) +""" diff --git a/src/Fantomas.Tests/PatternMatchingTests.fs b/src/Fantomas.Tests/PatternMatchingTests.fs index 91ec1d32dd..51a936244c 100644 --- a/src/Fantomas.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Tests/PatternMatchingTests.fs @@ -1123,7 +1123,7 @@ match foo with let range = getRangeBetween "keyword" headToken headToken let info = - Trivia.Create(Keyword(headToken)) range + Trivia.Create (Keyword(headToken)) range |> List.prependItem foundTrivia getTriviaFromTokensThemSelves allTokens rest info diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 4126720f48..7f3b285116 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2001,16 +2001,13 @@ and genExpr astContext synExpr ctx = let sepSpaceAfterFunctionName = let sepSpaceBasedOnSetting e = match e with + | Paren _ -> sepSpace | UppercaseSynExpr -> (fun ctx -> onlyIf ctx.Config.SpaceBeforeUppercaseInvocation sepSpace ctx) | LowercaseSynExpr -> (fun ctx -> onlyIf ctx.Config.SpaceBeforeLowercaseInvocation sepSpace ctx) - match List.tryHead es with - | None -> - match e with - | Paren _ -> sepSpace - | _ -> sepSpaceBasedOnSetting e - | Some (SimpleExpr _) -> sepSpace - | _ -> sepSpaceBasedOnSetting e + match es with + | [] -> sepSpaceBasedOnSetting e + | _ -> sepSpace let short = genExpr astContext e @@ -3216,8 +3213,8 @@ and genApp astContext e es ctx = (fun ctx -> match es with | [] -> false - | [ h ] - | h :: _ -> addSpaceBeforeParensInFunCall e h ctx) + | [ h ] -> addSpaceBeforeParensInFunCall e h ctx + | _ -> true) sepSpace sepNone