Skip to content

Commit

Permalink
Print trivia before SynTypeDefnSimpleRepr.Union in signature files. F…
Browse files Browse the repository at this point in the history
…ixes #1560. (#1566)
  • Loading branch information
nojaf authored Apr 1, 2021
1 parent 44926de commit 82615ce
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
27 changes: 27 additions & 0 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,3 +1298,30 @@ exception FileNameNotResolved of string (*description of searched locations*) *
exception LoadedSourceNotFoundIgnoring of string * range (*filename*)
"""

[<Test>]
let ``comment above first DU case`` () =
formatSourceString
true
"""
namespace Baz
type 'a Bar =
///
| Foo
///
| Quux
"""
config
|> prepend newline
|> should
equal
"""
namespace Baz
type 'a Bar =
///
| Foo
///
| Quux
"""
15 changes: 8 additions & 7 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3742,13 +3742,14 @@ and genSigTypeDefn astContext (SigTypeDef (ats, px, ao, tds, tcs, tdr, ms, s, pr
| xs ->
indent
+> sepNln
+> opt sepNln ao' genAccess
+> col
sepNln
xs
(genUnionCase
{ astContext with
HasVerticalBar = true })
+> (opt sepNln ao' genAccess
+> col
sepNln
xs
(genUnionCase
{ astContext with
HasVerticalBar = true })
|> genTriviaFor SynTypeDefnSimpleRepr_Union tdr.Range)

typeName
+> sepEq
Expand Down

0 comments on commit 82615ce

Please sign in to comment.