Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit SynExpr.IfThenElse #1258

Closed
5 of 6 tasks
nojaf opened this issue Nov 18, 2020 · 0 comments · Fixed by #1282
Closed
5 of 6 tasks

Revisit SynExpr.IfThenElse #1258

nojaf opened this issue Nov 18, 2020 · 0 comments · Fixed by #1282

Comments

@nojaf
Copy link
Contributor

nojaf commented Nov 18, 2020

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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant