Skip to content

Commit

Permalink
DotGetApp inside multiline infix expression should indent. Fixes #1529.…
Browse files Browse the repository at this point in the history
… (#1530)
  • Loading branch information
nojaf committed Mar 21, 2021
1 parent 09a26b1 commit f79dfe5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/Fantomas.Tests/DotGetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -967,3 +967,37 @@ let PublishValueDefn cenv env declKind (vspec: Val) =
()
"""

[<Test>]
let ``DotGetApp inside multiline infix expression should indent, 1529`` () =
formatSourceString
false
"""
type Foobar =
member tcConfig.IsSystemAssembly (filename: string) =
try
FileSystem.SafeExists filename &&
((tcConfig.GetTargetFrameworkDirectories() |> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
(tcConfig.FxResolver.GetSystemAssemblies().Contains (fileNameWithoutExtension filename)) ||
tcConfig.FxResolver.IsInReferenceAssemblyPackDirectory filename)
with _ ->
false
"""
config
|> prepend newline
|> should
equal
"""
type Foobar =
member tcConfig.IsSystemAssembly(filename: string) =
try
FileSystem.SafeExists filename
&& ((tcConfig.GetTargetFrameworkDirectories()
|> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName filename))
|| (tcConfig
.FxResolver
.GetSystemAssemblies()
.Contains(fileNameWithoutExtension filename))
|| tcConfig.FxResolver.IsInReferenceAssemblyPackDirectory filename)
with _ -> false
"""
3 changes: 2 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,8 @@ and genExprInMultilineInfixExpr astContext e =
(sepNlnConsideringTriviaContentBeforeForMainNode (synExprToFsAstType e) e.Range
+> genExpr astContext e)
)
| Paren (_, InfixApp (_, _, DotGet _, _), _, _) -> atCurrentColumnIndent (genExpr astContext e)
| Paren (_, InfixApp (_, _, DotGet _, _), _, _)
| Paren (_, DotGetApp _, _, _) -> atCurrentColumnIndent (genExpr astContext e)
| _ -> genExpr astContext e

and genLidsWithDots (lids: (string * range) list) =
Expand Down

0 comments on commit f79dfe5

Please sign in to comment.