fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
776 stars 194 forks source link

Indentation misses a space after boolean operator when multi-line #3117

Closed ursenzler closed 2 months ago

ursenzler commented 2 months ago

Issue created from fantomas-online

Code

let imTrue = true
let list = [ 1;2;3]

let value = imTrue && list |> List.map (fun i -> i*2) |> Set |> Set.toList |> List.toSet |> Set.isEmpty

Result

let imTrue = true
let list = [ 1; 2; 3 ]

let value =
    imTrue
    && list
       |> List.map (fun i -> i * 2)
       |> Set
       |> Set.toList
       |> List.toSet
       |> Set.isEmpty

Problem description

The result should look like (one space more indentation):

let imTrue = true
let list = [ 1; 2; 3 ]

let value =
    imTrue
    && list
        |> List.map (fun i -> i * 2)
        |> Set
        |> Set.toList
        |> List.toSet
        |> Set.isEmpty

The F# style guidelines use 4 spaces in their examples. I stumbled over this because I use IndentRainbox Plugin in Rider and it shows the indentation as wrong, which is a bit annoying.

Thanks for all your work.

Extra information

Options

Fantomas main branch at 1/1/1990

Default Fantomas configuration

nojaf commented 2 months ago

Hello, thank you for your report!

This is a very complex problem to address. Operators in F# are challenging to format while ensuring the results remain valid. I took a brief look at the code, and one change in that area leads to multiple tests failing.

That being said, if you're interested in diving into this, please feel free! I would be open to revisiting some of our current practices after receiving approval from the style guide.

However, if you're not interested in submitting a PR, I would prefer to close this issue. It's unlikely that someone will jump into this complex situation, so I don't see the point in keeping it open if there's not enough motivation to act.

ursenzler commented 2 months ago

I don't think it's a big enough problem to spend so much time on. Thanks for taking a look.

nojaf commented 2 months ago

Thank you for your understanding. This is indeed a larger epic than just a single alignment problem. If anyone would like to revisit this in the future, please feel free to speak up.