From 4078ca313f0242ba655641b07fa12eec434791a5 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 18 Mar 2021 08:47:23 +0100 Subject: [PATCH] Further indent multiline DotGet inside infix expression. Fixes #1521. (#1524) --- 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 773a7474e8..267a7d3f67 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) =