diff --git a/src/Fantomas.Core.Tests/DallasTests.fs b/src/Fantomas.Core.Tests/DallasTests.fs index 75c2d0be74..94b0c586e1 100644 --- a/src/Fantomas.Core.Tests/DallasTests.fs +++ b/src/Fantomas.Core.Tests/DallasTests.fs @@ -3,6 +3,7 @@ open NUnit.Framework open FsUnit open Fantomas.Core.Tests.TestHelper +open Fantomas.Core.FormatConfig [] let ``proof of concept`` () = @@ -1850,9 +1851,7 @@ let someTest input1 input2 = Expect.equal input1 input2 "didn't equal" } """ - { config with - ExperimentalStroustrupStyle = true - MultilineBlockBracketsOnSameColumn = true } + { config with MultilineBracketStyle = ExperimentalStroustrup } |> prepend newline |> should equal diff --git a/src/Fantomas.Core/CodePrinter2.fs b/src/Fantomas.Core/CodePrinter2.fs index 3b34af9241..0fae9f4d1b 100644 --- a/src/Fantomas.Core/CodePrinter2.fs +++ b/src/Fantomas.Core/CodePrinter2.fs @@ -3,6 +3,7 @@ open System open Fantomas.Core.Context open Fantomas.Core.SyntaxOak +open Fantomas.Core.FormatConfig let noBreakInfixOps = set [| "="; ">"; "<"; "%" |] let newLineInfixOps = set [ "|>"; "||>"; "|||>"; ">>"; ">>=" ] @@ -2553,7 +2554,7 @@ let genPat (p: Pattern) = let multilineExpressionIfAlignBrackets = ifAlignBrackets multilineRecordExprAlignBrackets multilineRecordExpr - + fun ctx -> let size = getRecordSize ctx node.Fields genNode node (isSmallExpression size smallRecordExpr multilineExpressionIfAlignBrackets) ctx @@ -3330,10 +3331,7 @@ let genTypeDefn (td: TypeDefn) = +> genSingleTextNode node.ClosingBrace let multilineExpression (ctx: Context) = - if - ctx.Config.MultilineBlockBracketsOnSameColumn - || (List.exists (fun (fieldNode: FieldNode) -> fieldNode.XmlDoc.IsSome) node.Fields) - then + let aligned = let msIsEmpty = List.isEmpty members (ifElseCtx @@ -3351,7 +3349,12 @@ let genTypeDefn (td: TypeDefn) = +> sepNlnTypeAndMembers typeDefnNode +> genMemberDefnList members) ctx - else + + match ctx.Config.MultilineBracketStyle with + | Aligned + | ExperimentalStroustrup -> aligned + | Classic when (List.exists (fun (fieldNode: FieldNode) -> fieldNode.XmlDoc.IsSome) node.Fields) -> aligned + | Classic -> (sepNlnUnlessLastEventIsNewline +> opt (indent +> sepNln) node.Accessibility genSingleTextNode +> genSingleTextNodeSuffixDelimiter node.OpeningBrace diff --git a/src/Fantomas.Core/Fantomas.Core.fsproj b/src/Fantomas.Core/Fantomas.Core.fsproj index aa18a5782c..fe1d4b0169 100644 --- a/src/Fantomas.Core/Fantomas.Core.fsproj +++ b/src/Fantomas.Core/Fantomas.Core.fsproj @@ -20,11 +20,6 @@ - - - - - diff --git a/src/Fantomas.Core/FormatConfig.fs b/src/Fantomas.Core/FormatConfig.fs index cc41a6aca8..32d55fdcfb 100644 --- a/src/Fantomas.Core/FormatConfig.fs +++ b/src/Fantomas.Core/FormatConfig.fs @@ -218,7 +218,7 @@ type FormatConfig = // [] // [] // [] - + [] [] [] @@ -233,6 +233,9 @@ type FormatConfig = [] StrictMode: bool } + member this.ExperimentalStroustrupStyle = + this.MultilineBracketStyle = ExperimentalStroustrup + static member Default = { IndentSize = 4 MaxLineLength = 120