Skip to content

Indentation of Else block #1361

Open
Open
@Smaug123

Description

@Smaug123

Issue created from fantomas-online

Code

let foo () =
    if a then 3 else
    doThing()
    5

Result

let foo () =
    if a then
        3
    else
        doThing ()
        5

Problem description

I didn't realise this would be a problem for us, but sadly we have several places where we kind of rely on the ability to if/then/else without indentation. In functions with a lot of different possible outcomes, the code really marches off to the right unless we stick the else at the same indentation as the parent.

That is, because the original code had the else block unindented, it would be great if the output also had the else block unindented:

let foo () =
    if a then
        3
    else
    doThing ()
    5

I definitely understand why Fantomas does what it does, but do you think it would be reasonable to respect the user's choice not to indent else blocks?

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas Master at 01/09/2021 08:58:25 - ca42f0d

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions