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:
- I have read the Contribution Guidelines.
- I have searched both open and closed suggestions on this site and believe this is not a duplicate
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:
- https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting#formatting-if-expressions
- Formatting if expressions can have problems when applying the short syntax style. dotnet/docs#21530
- This suggestion is part of the G-Research style guide (please add a link to section if so)