-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Misplaced comment in "else if" #3011
Comments
So, the style guide settled on formatting multiline conditions like: // ✔️ OK, but better to refactor, see below
if
complexExpression a b && env.IsDevelopment()
|| someFunctionToCall
aVeryLongParameterNameOne
aVeryLongParameterNameTwo
aVeryLongParameterNameThree
then
e1
else
e2
// ✔️The same applies to nested `elif` or `else if` expressions
if a then
b
elif
someLongFunctionCall
argumentOne
argumentTwo
argumentThree
argumentFour
then
c
else if
someOtherLongFunctionCall
argumentOne
argumentTwo
argumentThree
argumentFour
then
d
It rings a bell that putting anything between the From a technical point of view, we view your entire |
I think it would be more logical to assign the comment to the if bar then
a <- 1
else
// elif comment
if
// baz comment
baz
then
quux <- 3 should not format to: if bar then
a <- 1
else if
// elif comment
// baz comment
baz
then
quux <- 3 but instead: if bar then
a <- 1
// elif comment
else if
// baz comment
baz
then
quux <- 3 |
Feel free to investigate how much fun that would be 😉 |
Issue created from fantomas-online
Code
Result
Problem description
The comment has been moved with respect to the
if
statement. Expected instead was:(or, in my own codebase with ExperimentalKeepIndentInBranch, I expected no change to the formatting).
Extra information
Options
Fantomas main branch at 2023-12-06T16:47:58Z - 0f8ee23
Default Fantomas configuration
Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.
The text was updated successfully, but these errors were encountered: