Skip to content

Commit

Permalink
Ignore SynExpr.CompExpr as TriviaNode candidate. Fixes #990. (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Aug 19, 2020
1 parent e7a9b75 commit 29f524e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Fantomas.Tests/ListTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,4 +1636,24 @@ let choices: Foo list =
[ yield!
// Test
[ Foo 2 ] ]
"""
"""

[<Test>]
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 ]
"""
1 change: 1 addition & 0 deletions src/Fantomas/Trivia.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 29f524e

Please sign in to comment.