diff --git a/src/Fantomas.Tests/UnionTests.fs b/src/Fantomas.Tests/UnionTests.fs index 36c2726096..663576c066 100644 --- a/src/Fantomas.Tests/UnionTests.fs +++ b/src/Fantomas.Tests/UnionTests.fs @@ -559,3 +559,17 @@ type CardValue = yield King ] """ + +[] +let ``comment after enum field, 1247`` () = + formatSourceString false """ +type Foo = + | Bar = 3 // Foo + | Baz = 5 // Eee +""" config + |> prepend newline + |> should equal """ +type Foo = + | Bar = 3 // Foo + | Baz = 5 // Eee +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 7a25b85c69..5776814d3b 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -3650,7 +3650,9 @@ and genEnumCase astContext (EnumCase (ats, px, _, (_, _)) as node) = let genCase (ctx: Context) = let expr = match node with - | EnumCase (_, _, identInAST, (c, r)) -> !-identInAST +> !- " = " +> genConst c r + | EnumCase (_, _, identInAST, (c, r)) -> + !-identInAST +> !- " = " +> genConst c r + |> genTriviaFor EnumCase_ r expr ctx