diff --git a/docs/Documentation.md b/docs/Documentation.md index 5648c83828..06953fbc13 100644 --- a/docs/Documentation.md +++ b/docs/Documentation.md @@ -53,7 +53,7 @@ To illustrate, here is a code fragment with `--indent 2`: ``` - `--pageWidth `: `number` has to be an integer greater or equal to 60. This preference sets the column where we break F# constructs into new lines. -The default value is 80. To see its effects, please take a look at some [output files](tests/stackexchange_output) with `--pageWidth 90` preference. +The default value is 120. To see its effects, please take a look at some [output files](tests/stackexchange_output) with `--pageWidth 90` preference. - `--semicolonEOL`: add semicolons at the end of lines e.g. diff --git a/src/Fantomas.Tests/CommentTests.fs b/src/Fantomas.Tests/CommentTests.fs index 215d144c5a..c63c37fc05 100644 --- a/src/Fantomas.Tests/CommentTests.fs +++ b/src/Fantomas.Tests/CommentTests.fs @@ -712,4 +712,37 @@ if true then 1 else //comment 0 +""" + +[] +let ``comments for enum cases, 572``() = + formatSourceString false """type A = + /// Doc for CaseA + | CaseA = 0 + /// Doc for CaseB + | CaseB = 1 + /// Doc for CaseC + | CaseC = 2""" config + |> should equal """type A = + /// Doc for CaseA + | CaseA = 0 + /// Doc for CaseB + | CaseB = 1 + /// Doc for CaseC + | CaseC = 2 +""" + formatSourceString false """type A = + // Comment for CaseA + | CaseA = 0 + // Comment for CaseB + | CaseB = 1 + // Comment for CaseC + | CaseC = 2""" config + |> should equal """type A = + // Comment for CaseA + | CaseA = 0 + // Comment for CaseB + | CaseB = 1 + // Comment for CaseC + | CaseC = 2 """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 9951d63abe..3ffedd848c 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -1741,6 +1741,7 @@ and genEnumCase astContext (EnumCase(ats, px, _, (_,r)) as node) = !- ident.idText +> !- " = " +> genConst c r genPreXmlDoc px + +> genTriviaBeforeClausePipe node.Range +> ifElse astContext.HasVerticalBar sepBar sepNone +> genOnelinerAttributes astContext ats +> genCase