Skip to content

Commit

Permalink
genTrivia for SynEnumCase. Fixes fsprojects#1247.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Nov 13, 2020
1 parent 0ce38c1 commit f8358a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/Fantomas.Tests/UnionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,17 @@ type CardValue =
yield King
]
"""

[<Test>]
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
"""
4 changes: 3 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f8358a3

Please sign in to comment.