diff --git a/src/Fantomas.Tests/ListTests.fs b/src/Fantomas.Tests/ListTests.fs index 436575506b..38e733dae7 100644 --- a/src/Fantomas.Tests/ListTests.fs +++ b/src/Fantomas.Tests/ListTests.fs @@ -1636,4 +1636,24 @@ let choices: Foo list = [ yield! // Test [ Foo 2 ] ] -""" \ No newline at end of file +""" + +[] +let ``preserve comment above first element of list, 990`` () = + formatSourceString false """ +let x = [ + // comment + 1 + // another comment + 2 +] +""" config + |> prepend newline + |> should equal """ +let x = + [ + // comment + 1 + // another comment + 2 ] +""" diff --git a/src/Fantomas/Trivia.fs b/src/Fantomas/Trivia.fs index 61b7f3fd0e..e58218ca0b 100644 --- a/src/Fantomas/Trivia.fs +++ b/src/Fantomas/Trivia.fs @@ -35,6 +35,7 @@ let filterNodes nodes = "SynTypeDefnRepr.ObjectModel" "TypeDefnSig" "SynTypeDefnSigRepr.ObjectModel" + "SynExpr.CompExpr" ] nodes |> List.filter (fun (n: Node) -> not (Set.contains n.Type filterOutNodeTypes))