Skip to content

Commit

Permalink
Merge pull request fsprojects#1046 from nojaf/fix-1043
Browse files Browse the repository at this point in the history
Print trivia for UnionCase
  • Loading branch information
nojaf committed Aug 28, 2020
2 parents 31b3e6c + 8440484 commit faf5419
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Fantomas.Tests/UnionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,29 @@ type Foo =
| One = 0x00000001
| Two = 0x00000002
"""

[<Test>]
let ``comment after union case, 1043`` () =
formatSourceString false """
module FantomasTools.Client.FantomasOnline.Model
open FantomasOnline.Shared
type FantomasMode =
| V2
| V3
| V4
| Preview // master branch
""" config
|> prepend newline
|> should equal """
module FantomasTools.Client.FantomasOnline.Model
open FantomasOnline.Shared
type FantomasMode =
| V2
| V3
| V4
| Preview // master branch
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,7 @@ and genUnionCase astContext (UnionCase(ats, px, _, s, UnionCaseType fs) as node)
+> ifElse astContext.HasVerticalBar sepBar sepNone
+> genOnelinerAttributes astContext ats -- s
+> colPre wordOf sepStar fs (genField { astContext with IsUnionField = true } "")
|> genTriviaFor UnionCase_ node.Range

and genEnumCase astContext (EnumCase(ats, px, _, (_,_)) as node) =
let genCase (ctx: Context) =
Expand Down

0 comments on commit faf5419

Please sign in to comment.