From 19c88db3a1cb0e3f8f217b88b7eb59802c7c44f3 Mon Sep 17 00:00:00 2001 From: Viridovics Date: Fri, 11 Feb 2022 10:09:54 +0300 Subject: [PATCH] Delete spaces for named arguments (#2038) * delete spaces for named arguments * restore space for multiline function argument * delete spaces for PatWithIdent * fix build * restore spaces * revert changes for CodePrinter.fs Co-authored-by: Florian Verdonck --- src/Fantomas.Tests/AppTests.fs | 28 ++++++++++++++++++++++ src/Fantomas.Tests/PatternMatchingTests.fs | 20 ++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/Fantomas.Tests/AppTests.fs b/src/Fantomas.Tests/AppTests.fs index f2c4c5c95d..6adb60fad5 100644 --- a/src/Fantomas.Tests/AppTests.fs +++ b/src/Fantomas.Tests/AppTests.fs @@ -751,3 +751,31 @@ x |> f // some comment """ x |> f // some comment """ + +[] +let ``single named arguments should have space surrounding the '=', 1877`` () = + formatSourceString + false + """ +let makeStreamReader x = new System.IO.StreamReader(path=x)""" + config + |> prepend newline + |> should + equal + """ +let makeStreamReader x = new System.IO.StreamReader(path = x) +""" + +[] +let ``multiple named arguments should have space surrounding the '=', 1877`` () = + formatSourceString + false + """ +let makeStreamReader x y = new StreamReader(arg1=x, arg2=y)""" + config + |> prepend newline + |> should + equal + """ +let makeStreamReader x y = new StreamReader(arg1 = x, arg2 = y) +""" diff --git a/src/Fantomas.Tests/PatternMatchingTests.fs b/src/Fantomas.Tests/PatternMatchingTests.fs index 002f691f87..91ec1d32dd 100644 --- a/src/Fantomas.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Tests/PatternMatchingTests.fs @@ -2047,3 +2047,23 @@ match! | None -> false | Some balance -> someRetrievedBalance = balance """ + +[] +let ``single line named fields in a pattern matching should have space surrounding the '=', 1877`` () = + formatSourceString + false + """ +let examineData x = + match data with + | OnePartData(part1 = p1) -> p1 + | TwoPartData(part1 = p1; part2=p2) -> p1 + p2""" + config + |> prepend newline + |> should + equal + """ +let examineData x = + match data with + | OnePartData (part1 = p1) -> p1 + | TwoPartData (part1 = p1; part2 = p2) -> p1 + p2 +"""