Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genTrivia for SynEnumCase #1248

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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