From fc771565587ab3f44792b58c7e727ecd8aeb2f66 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 10 Sep 2020 22:41:43 +0200 Subject: [PATCH] Print comment after closing parenthesis of SynType.Paren. Fixes #1128 --- src/Fantomas.Tests/UnionTests.fs | 18 ++++++++++++++++++ src/Fantomas/CodePrinter.fs | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Fantomas.Tests/UnionTests.fs b/src/Fantomas.Tests/UnionTests.fs index e3dfce963a..5ec079e769 100644 --- a/src/Fantomas.Tests/UnionTests.fs +++ b/src/Fantomas.Tests/UnionTests.fs @@ -501,3 +501,21 @@ type UnresolvedAssemblyReference = UnresolvedAssemblyReference of string * Assem type ResolvedExtensionReference = ResolvedExtensionReference of string * AssemblyReference list * Tainted list """ + +[] +let ``comment after union fields wrapped in parenthesis, 1128`` () = + formatSourceString false """ +module Test + +type t = + | Beta of (unit -> unit) /// comment is gone + | Alpha of bool /// comment stays +""" config + |> prepend newline + |> should equal """ +module Test + +type t = + | Beta of (unit -> unit) /// comment is gone + | Alpha of bool /// comment stays +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index e2c83c38a1..738cc81ecd 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -3702,7 +3702,11 @@ and genType astContext outerBracket t = +> sepCloseAnonRecd fun (ctx: Context) -> isShortExpression ctx.Config.MaxRecordWidth shortExpression longExpression ctx - | TParen (innerT) -> sepOpenT +> loop innerT +> sepCloseT + | TParen (innerT) -> + sepOpenT + +> loop innerT + +> sepCloseT + +> leaveNodeTokenByName current.Range RPAREN | t -> failwithf "Unexpected type: %O" t and loopTTupleList =