-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Fix: print line comment after arrow in lamda between paranthesis #557
Conversation
// Comment 1 | ||
if b then () | ||
// Comment 2 | ||
else () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO there should be indent after else
.
then // c3 | ||
b // c4 | ||
else // c5 | ||
if // c6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no indent after else
if a then | ||
b | ||
else // meh | ||
if c then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no indent after else
The no indentation after the
I consider The fsharp lang ref seems to confirm this.
So that is why no indentation. In an extreme example I wouldn't imagine you would write the following code like this right? if aaaa then
meh
else
if bbbb then
fooo
else
if ccc then
baaarrr
else
if dddd then
meehhh
else
() |
IMO this means only that
I know it is valid code, I just always considered this as bad style. But "it is same as
Yeah, I would write it with To move forward, I think we can merge this, and raise an issue in style docs to clarify this. |
I've created dotnet/docs#15922, we can always later change the formatting to whatever the outcome ends up being. |
@nojaf Thanks! |
# Conflicts: # src/Fantomas.Tests/LambdaTests.fs # src/Fantomas/CodePrinter.fs
After this PR has been merged, is there a way to configure fantomas to make ifs always multi-line? |
@knocte try setting |
In #539 I tried to fix bug #534 and by I ended up with two broken tests that were somewhat strange and debatable.
This PR contains the same fix for #534 and also refactors the way
SynExpr.IfThenElse
is formatted.As close to the F# style guide as possible.
In the case of
the guide leaves some room for interpretation. What is "longer" exactly?
Because of this question I introduced a new setting
MaxIfThenElseShortWidth
to let the user control this.The main motivation to rewrite the formatting of
SynExpr.IfThenElse
is the support for comments around keywords (if
,elif
,else if
), this have been tested extensively inIfThenElseTests.fs
.