Skip to content

Revisit SynExpr.IfThenElse #1258

Closed
@nojaf

Description

There was a recent change in the MS style guide regarding the if/then/else formatting.
See https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting#formatting-if-expressions
and dotnet/docs#21530.

Setting fsharp_keep_if_then_in_same_line could become obsolete.
fsharp_max_if_then_else_short_width could gain a new meaning, as the max length for writing an if cond then e1 else e2 in one line.

The existing way of Fantomas deals with this problem is the previous syntax where if/then/else are formatted in three lines.

Pros and Cons

The advantages of making this adjustment to Fantomas are adhering to the style guides.
It will also simply the code base as way of formatting if/then/else is dropped. Could improve performance.

The disadvantages of making this adjustment to Fantomas are changing the behavior of two settings.

Examples

if somethingLongButNotMultilineCausingThreeliner then
    foo
else
    bar

is now formatted as

if somethingLongButNotMultilineCausingThreeliner
then foo
else bar

should be

if somethingLongButNotMultilineCausingThreeliner then 
    foo
else
    bar

according to the guide.

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S to M.

Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

  • This is not a breaking change to Fantomas. (Would not be binary breaking)
  • I or my company would be willing to help implement and/or test this
  • This suggestion is part of the Microsoft style guide:

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions