From 6869e2e9219adb23a0f5ce4ae110453223834b22 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Sun, 18 Jul 2021 14:29:49 +0200 Subject: [PATCH] Unindent after record and before members. Fixes #1824. (#1833) --- ...ineBlockBracketsOnSameColumnRecordTests.fs | 32 ++++++++++++++++++ src/Fantomas.Tests/SignatureTests.fs | 33 +++++++++++++++++-- src/Fantomas/CodePrinter.fs | 4 +-- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs b/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs index eabbb21130..c19835c67b 100644 --- a/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs +++ b/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs @@ -1135,3 +1135,35 @@ module WatcherTests = () """ + +[] +let ``a record type with accessibility modifier and members, 1824`` () = + formatSourceString + true + """ +namespace Thing + +type Foo = + private + { + Bar : int + Qux : string + } + static member Baz : int +""" + config + |> prepend newline + |> should + equal + """ +namespace Thing + +type Foo = + private + { + Bar : int + Qux : string + } + + static member Baz : int +""" diff --git a/src/Fantomas.Tests/SignatureTests.fs b/src/Fantomas.Tests/SignatureTests.fs index 5f00634516..4d00b4f8e7 100644 --- a/src/Fantomas.Tests/SignatureTests.fs +++ b/src/Fantomas.Tests/SignatureTests.fs @@ -1513,8 +1513,8 @@ and [] Bang = { LongNameBarBarBarBarBarBarBar: int } - /// - override GetHashCode : unit -> int + /// + override GetHashCode : unit -> int """ [] @@ -1572,3 +1572,32 @@ type Bar = * item : int list -> LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong """ + +[] +let ``a record type with accessibility modifier and members`` () = + formatSourceString + true + """ +namespace Thing + +type Foo = + private + { + Bar : int + Qux : string + } + static member Baz : int +""" + config + |> prepend newline + |> should + equal + """ +namespace Thing + +type Foo = + private + { Bar: int + Qux: string } + static member Baz : int +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index a84c7e88fc..e1cea0c6f5 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -3928,9 +3928,9 @@ and genSigSimpleRecord tdr ms ao' fs astContext = +> col sepSemiNln fs (genField astContext "") ) +> sepCloseS + +> optSingle (fun _ -> unindent) ao' +> sepNlnBetweenSigTypeAndMembers tdr ms +> colPre sepNln sepNln ms (genMemberSig astContext) - +> optSingle (fun _ -> unindent) ao' and genSigSimpleRecordAlignBrackets tdr ms ao' fs astContext = // the typeName is already printed @@ -3946,9 +3946,9 @@ and genSigSimpleRecordAlignBrackets tdr ms ao' fs astContext = +> unindent +> sepNln +> sepCloseSFixed + +> optSingle (fun _ -> unindent) ao' +> sepNlnBetweenSigTypeAndMembers tdr ms +> colPre sepNln sepNln ms (genMemberSig astContext) - +> onlyIf (Option.isSome ao') unindent and genMemberSig astContext node = let range, mainNodeName =