Skip to content

Commit

Permalink
Respect current column when dotget is found in quotation. Fixes #2154. (
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Mar 15, 2022
1 parent 9059695 commit c11c773
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Fantomas.Tests/DotGetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,3 +1360,20 @@ module Program =
builder.Build().RunAsync() |> ignore
0
"""

[<Test>]
let ``dotget inside a quotation, 2154`` () =
formatSourceString
false
"""
(fun (Singleton arg) -> <@@ ((%%arg: Indicators) :> IIndicators).AsyncGetIndicator(indicatorIdVal) @@>)
"""
config
|> prepend newline
|> should
equal
"""
(fun (Singleton arg) ->
<@@ ((%%arg: Indicators) :> IIndicators)
.AsyncGetIndicator(indicatorIdVal) @@>)
"""
6 changes: 5 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,11 @@ and genExpr astContext synExpr ctx =
| NullExpr -> !- "null"
// Not sure about the role of e1
| Quote (_, e2, isRaw) ->
let e = genExpr astContext e2
let e =
match e2 with
| DotGetApp _ -> atCurrentColumnIndent (genExpr astContext e2)
| _ -> genExpr astContext e2

ifElse isRaw (!- "<@@ " +> e -- " @@>") (!- "<@ " +> e -- " @>")
| TypedExpr (TypeTest, e, t) ->
genExpr astContext e -- " :? "
Expand Down

0 comments on commit c11c773

Please sign in to comment.