You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a completely new request which we've never asked you for before, not a bug. (In general the ExperimentalKeepIndentInBranch feature works great nowadays, and I now instinctively expect it to do the right thing!)
If ExperimentalKeepIndentInBranch, it would be great if we could retain the indentation when there's a one-line "deal with some particular case" that we've reformatted onto multiple lines. I think this new pattern should only fire if the format is like this:
if blah then baz else
more stuff at the same level ofindentationastheinitial`if`
That is, the following reformatting shouldn't take place:
if blah then baz else foo
//if blah then
baz
else
foo // note the lack of indent, which here would be incorrect
Rationale: if I've "clearly been trying" to keep the main body of my else block unindented, by explicitly putting it at the same level of indentation as the if keyword, then I think we shouldn't break that attempt merely because we reformatted the body of the if branch.
The actual code in the wild which triggered me to write this report is:
I or my company would be willing to help fix this.
I would like a release if this problem is solved.
Options
Fantomas main branch at 2023-10-30T10:39:28Z - 3f293e7
{ config with
ExperimentalKeepIndentInBranch =true}
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:
I've encountered this myself as well. I see your point.
The additional trigger should be the elseBranch matching the indentation of the if keyword right?
I'll take a look at this.
Issue created from fantomas-online
Code
Result
Desired result
Problem description
This is a completely new request which we've never asked you for before, not a bug. (In general the
ExperimentalKeepIndentInBranch
feature works great nowadays, and I now instinctively expect it to do the right thing!)If ExperimentalKeepIndentInBranch, it would be great if we could retain the indentation when there's a one-line "deal with some particular case" that we've reformatted onto multiple lines. I think this new pattern should only fire if the format is like this:
That is, the following reformatting shouldn't take place:
Rationale: if I've "clearly been trying" to keep the main body of my
else
block unindented, by explicitly putting it at the same level of indentation as theif
keyword, then I think we shouldn't break that attempt merely because we reformatted the body of theif
branch.The actual code in the wild which triggered me to write this report is:
Extra information
Options
Fantomas main branch at 2023-10-30T10:39:28Z - 3f293e7
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: