Skip to content

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

Description

@Linschlager

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

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions