fsprojects / fantomas

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

Stroustrup formatting breaks array containing just empty line or comment #3098

Open Linschlager opened 1 week ago

Linschlager commented 1 week ago

Issue created from fantomas-online

Code

let myArray = [|

  |]

let myArray2 = [|
  // Some comment
  |]

Result

let myArray = [|

|]

let myArray2 = [|
// Some comment
|]

Problem description

When trying to format an array with an empty line inside, Fantomas tries to indent it as if there were values inside. This, for some reason, is not allowed and breaks the code.

If there is no empty line inside, it properly removes the newline and formats it validly as such:

let myArray = [||]

Extra information

Options

Fantomas main branch at 03/07/2024

    { config with
                MultilineBracketStyle = stroustrup }

Did you know that you can ignore files when formatting by using a .fantomasignore file? PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

nojaf commented 1 week ago

Hello, thank you for reporting this issue. This guide could be useful to investigate the problem. Are you interested in sending a contribution for this?