fantomas
fantomas copied to clipboard
Idempotency problem: IndentSize = 2 broke offside rule
Issue created from fantomas-online
Formatted code
This is already broken, see sharplab.io for my original code (which works as expected)
open System.IO
let f (x: StreamReader) =
fun () ->
match x.ReadLine() with
| null -> None
| ln -> Some(ln, ())
|> Seq.unfold
<| ()
for ln in f (File.OpenText @"\Windows\System32\Drivers\etc\hosts") do
printfn $"%s{ln}"
Reformatted code
This clarifies how ^^^ was broken
open System.IO
let f (x: StreamReader) =
fun () ->
match x.ReadLine() with
| null -> None
| ln -> Some(ln, ())
|> Seq.unfold
<| ()
for ln in f (File.OpenText @"\Windows\System32\Drivers\etc\hosts") do
printfn $"%s{ln}"
Problem description
Fantomas broke my code with IndentSize <= 3
where I suspect 3 came from "fun".Length
Extra information
- [x] The formatted result breaks my code.
- [ ] The formatted result gives compiler warnings.
- [x] I or my company would be willing to help fix this.
Options
Fantomas main branch at 2023-01-19T13:03:07Z - 813e63ab5c07fe5f5fd89328b9f5a7375ab43efb
{ config with
IndentSize = 2 }
Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?
Hey Kai, thanks for raising this issue. If you want to try fixing this issue by yourself, have a look at our documentation. Florians latest video is also a good resource.