diff --git a/src/Fantomas.Tests/DotGetTests.fs b/src/Fantomas.Tests/DotGetTests.fs index 34676f5bc1..640202c62f 100644 --- a/src/Fantomas.Tests/DotGetTests.fs +++ b/src/Fantomas.Tests/DotGetTests.fs @@ -1300,3 +1300,63 @@ db .Select(fun x -> x.Id) ) """ + +[] +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 = + + [] + let Main args = + let builder = WebAssemblyHostBuilder.CreateDefault(args) + builder.RootComponents.Add("#main") + builder.Services + .AddRemoting(builder.HostEnvironment) + .Services +#if (!DEBUG) + .RemoveAll() +#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 = + + [] + let Main args = + let builder = WebAssemblyHostBuilder.CreateDefault(args) + builder.RootComponents.Add("#main") + + builder + .Services + .AddRemoting( + builder.HostEnvironment + ) + .Services +#if (!DEBUG) + .RemoveAll() +#endif + |> ignore + + builder.Build().RunAsync() |> ignore + 0 +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index bf858e3dc2..4972a0e2ae 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -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}")