Skip to content

Commit

Permalink
Further indent multiline DotGet inside infix expression. Fixes #1521. (
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Mar 18, 2021
1 parent 53492fc commit 4078ca3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Fantomas.Tests/DotGetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -930,3 +930,40 @@ let retrySql<'a> =
)
.AsAsyncPolicy<'a>()
"""

[<Test>]
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))
()
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down

0 comments on commit 4078ca3

Please sign in to comment.