From 796010d579c8b3ac2e31ef751de6d3ac161a9d6a Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 18 Mar 2021 08:29:37 +0100 Subject: [PATCH] Further indent multiline DotGet inside infix expression. Fixes #1521. --- src/Fantomas.Tests/DotGetTests.fs | 37 +++++++++++++++++++++++++++++++ src/Fantomas/CodePrinter.fs | 1 + 2 files changed, 38 insertions(+) diff --git a/src/Fantomas.Tests/DotGetTests.fs b/src/Fantomas.Tests/DotGetTests.fs index 3794ebf87f..7e2cc2dec8 100644 --- a/src/Fantomas.Tests/DotGetTests.fs +++ b/src/Fantomas.Tests/DotGetTests.fs @@ -930,3 +930,40 @@ let retrySql<'a> = ) .AsAsyncPolicy<'a>() """ + +[] +let ``dotget in multiline infix expression, 1521`` () = + formatSourceString + false + """ +let PublishValueDefn cenv env declKind (vspec: Val) = + if (declKind = ModuleOrMemberBinding) && + ((GetCurrAccumulatedModuleOrNamespaceType env).ModuleOrNamespaceKind = Namespace) && + (Option.isNone vspec.MemberInfo) then + errorR(Error(FSComp.SR.tcNamespaceCannotContainValues(), vspec.Range)) + + if (declKind = ExtrinsicExtensionBinding) && + ((GetCurrAccumulatedModuleOrNamespaceType env).ModuleOrNamespaceKind = Namespace) then + errorR(Error(FSComp.SR.tcNamespaceCannotContainExtensionMembers(), vspec.Range)) + + () +""" + config + |> prepend newline + |> should + equal + """ +let PublishValueDefn cenv env declKind (vspec: Val) = + if (declKind = ModuleOrMemberBinding) + && ((GetCurrAccumulatedModuleOrNamespaceType env) + .ModuleOrNamespaceKind = Namespace) + && (Option.isNone vspec.MemberInfo) then + errorR (Error(FSComp.SR.tcNamespaceCannotContainValues (), vspec.Range)) + + if (declKind = ExtrinsicExtensionBinding) + && ((GetCurrAccumulatedModuleOrNamespaceType env) + .ModuleOrNamespaceKind = Namespace) then + errorR (Error(FSComp.SR.tcNamespaceCannotContainExtensionMembers (), vspec.Range)) + + () +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 7e0ef01c22..cf806fda6f 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2781,6 +2781,7 @@ and genExprInMultilineInfixExpr astContext e = (sepNlnConsideringTriviaContentBeforeForMainNode (synExprToFsAstType e) e.Range +> genExpr astContext e) ) + | Paren (_, InfixApp (_, _, DotGet _, _), _, _) -> atCurrentColumnIndent (genExpr astContext e) | _ -> genExpr astContext e and genLidsWithDots (lids: (string * range) list) =