diff --git a/src/Fantomas.Tests/ClassTests.fs b/src/Fantomas.Tests/ClassTests.fs index a8534dc651..84457655a1 100644 --- a/src/Fantomas.Tests/ClassTests.fs +++ b/src/Fantomas.Tests/ClassTests.fs @@ -382,4 +382,19 @@ type Exception with type Exception with member inline __.FirstLine = __.Message.Split([| Environment.NewLine |], StringSplitOptions.RemoveEmptyEntries).[0] -""" \ No newline at end of file +""" + +[] +let ``No extra new lines between type members, 569``() = + let original = """type A() = + + member this.MemberA = + if true then 0 else 1 + + member this.MemberB = + if true then 2 else 3 + + member this.MemberC = 0 +""" + + formatSourceString false original config |> should equal original diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 5cbca81cf7..f6f342b044 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -1950,8 +1950,17 @@ and genMemberDefnList astContext node = sepNlnConsideringTriviaContentBeforeWithAttributes xsh.Range attributes | _ -> sepNln + let sepMember (m:Composite) = + match m with + | Pair(x1,_) -> + let attributes = getRangesFromAttributesFromSynBinding x1 + sepNln +> sepNlnConsideringTriviaContentBeforeWithAttributes x1.RangeOfBindingSansRhs attributes + | Single x -> + let attributes = getRangesFromAttributesFromSynMemberDefinition x + sepNln +> sepNlnConsideringTriviaContentBeforeWithAttributes x.Range attributes + sepNln +> sepNlnFirstExpr - +> col (rep 2 sepNln) xs (function + +> colEx sepMember xs (function | Pair(x1, x2) -> genPropertyWithGetSet astContext (x1, x2) | Single x -> genMemberDefn astContext x) +> sepNln +> genMemberDefnList astContext ys