Skip to content

Commit

Permalink
Print comment after closing parenthesis of SynType.Paren. Fixes fspro…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 10, 2020
1 parent 0d32005 commit fc77156
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Fantomas.Tests/UnionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,21 @@ type UnresolvedAssemblyReference = UnresolvedAssemblyReference of string * Assem
type ResolvedExtensionReference =
ResolvedExtensionReference of string * AssemblyReference list * Tainted<ITypeProvider> list
"""

[<Test>]
let ``comment after union fields wrapped in parenthesis, 1128`` () =
formatSourceString false """
module Test
type t =
| Beta of (unit -> unit) /// comment is gone
| Alpha of bool /// comment stays
""" config
|> prepend newline
|> should equal """
module Test
type t =
| Beta of (unit -> unit) /// comment is gone
| Alpha of bool /// comment stays
"""
6 changes: 5 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3702,7 +3702,11 @@ and genType astContext outerBracket t =
+> sepCloseAnonRecd

fun (ctx: Context) -> isShortExpression ctx.Config.MaxRecordWidth shortExpression longExpression ctx
| TParen (innerT) -> sepOpenT +> loop innerT +> sepCloseT
| TParen (innerT) ->
sepOpenT
+> loop innerT
+> sepCloseT
+> leaveNodeTokenByName current.Range RPAREN
| t -> failwithf "Unexpected type: %O" t

and loopTTupleList =
Expand Down

0 comments on commit fc77156

Please sign in to comment.