Skip to content

Commit

Permalink
Print trivia for all lids in genLidsWithDots. Fixes #2098. (#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Feb 16, 2022
1 parent decb31b commit 840e11b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
60 changes: 60 additions & 0 deletions src/Fantomas.Tests/DotGetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,3 +1300,63 @@ db
.Select(fun x -> x.Id)
)
"""

[<Test>]
let ``trivia between LongIdentWithDots in DotGet, 2098`` () =
formatSourceString
false
"""
namespace PmaBolero.Client
open Microsoft.AspNetCore.Components.WebAssembly.Hosting
open Microsoft.Extensions.DependencyInjection.Extensions
open Bolero.Remoting.Client
module Program =
[<EntryPoint>]
let Main args =
let builder = WebAssemblyHostBuilder.CreateDefault(args)
builder.RootComponents.Add<Pages.Main.MyApp>("#main")
builder.Services
.AddRemoting(builder.HostEnvironment)
.Services
#if (!DEBUG)
.RemoveAll<Microsoft.Extensions.Http.IHttpMessageHandlerBuilderFilter>()
#endif
|> ignore
builder.Build().RunAsync() |> ignore
0
"""
config
|> prepend newline
|> should
equal
"""
namespace PmaBolero.Client
open Microsoft.AspNetCore.Components.WebAssembly.Hosting
open Microsoft.Extensions.DependencyInjection.Extensions
open Bolero.Remoting.Client
module Program =
[<EntryPoint>]
let Main args =
let builder = WebAssemblyHostBuilder.CreateDefault(args)
builder.RootComponents.Add<Pages.Main.MyApp>("#main")
builder
.Services
.AddRemoting(
builder.HostEnvironment
)
.Services
#if (!DEBUG)
.RemoveAll<Microsoft.Extensions.Http.IHttpMessageHandlerBuilderFilter>()
#endif
|> ignore
builder.Build().RunAsync() |> ignore
0
"""
4 changes: 1 addition & 3 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2832,9 +2832,7 @@ and genExprInMultilineInfixExpr astContext e =
| _ -> genExpr astContext e

and genLidsWithDots (lids: (string * range) list) =
optSingle (fun (_, r) -> enterNodeFor Ident_ r) (List.tryHead lids)
+> !- "."
+> col !- "." lids (fun (s, _) -> !-s)
col sepNone lids (fun (s, r) -> genTriviaFor Ident_ r !- $".{s}")

and genLidsWithDotsAndNewlines (lids: (string * range) list) =
col sepNln lids (fun (s, r) -> genTriviaFor Ident_ r !- $".{s}")
Expand Down

0 comments on commit 840e11b

Please sign in to comment.