From d13630906b9919c4416373495205fb339eadf80f Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 5 Feb 2020 21:25:43 +0100 Subject: [PATCH] Printing trivia after SynConst. Fixes #598. --- src/Fantomas.Tests/SynConstTests.fs | 29 ++++++++++++++++++++++++++++- src/Fantomas/CodePrinter.fs | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Fantomas.Tests/SynConstTests.fs b/src/Fantomas.Tests/SynConstTests.fs index 4f0326dc6b..327531aec2 100644 --- a/src/Fantomas.Tests/SynConstTests.fs +++ b/src/Fantomas.Tests/SynConstTests.fs @@ -100,4 +100,31 @@ let nullstr = "\u0000" |> should equal """ let nulchar = '\u0000' let nullstr = "\u0000" -""" \ No newline at end of file +""" + +[] +let ``line comment after custom measure type, 598`` () = + formatSourceString false """namespace Krach + +module Runner = + + let mPerSecond = 1000 // foo + + [] + type ProcessId = + class + end +""" config + |> prepend newline + |> should equal """ +namespace Krach + +module Runner = + + let mPerSecond = 1000 // foo + + [] + type ProcessId = + class + end +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 6e44fd8878..c9f7c1ad80 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2308,7 +2308,7 @@ and genConst (c:SynConst) (r:range) = | Measure m -> !- m genConstNumber c r +> measure - + |> genTrivia r and genConstNumber (c:SynConst) (r: range) = fun (ctx: Context) -> ctx.Trivia