-
Notifications
You must be signed in to change notification settings - Fork 635
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
Indent rule doesn't handle conditional assignment with line break after = operator #1575
Comments
I tried to fix this as a part of #1574, and made some progress. My change indents this example correctly: let foo =
if let foo {
bar
} else {
baaz
} but clearly leaves the indentation stack in the wrong state, because if you add a print statement on the following line it unexpectedly indents that to: let foo =
if let foo {
bar
} else {
baaz
}
print("Unexpectedly indented, whoops") and it also has multiple issues with the above example, outputting: let bullet =
if isRoot && (count == 0 || !willExpand) { "" }
else if count == 0 { "- " }
else if maxDepth <= 0 { "▹ " }
else { "▿ " }
print(bullet) |
@nicklockwood, I spent a few hours trying to fix this as a part of #1574 and wasn't able to make much progress. I was wondering if you could take a pass on it and see if you're able to implement a better fix than me. If so it would be much appreciated! |
@calda thanks for looking into this. Yeah the indent logic is not the easiest thing to decipher. I'll have a stab at it. |
@nicklockwood, I revisited this with a different approach in e6b98ed and was able to get all of the tests passing :) |
Landed in 0.52.11 |
The
indent
rule doesn't properly handle conditional assignment expressions when formatted with a line break after the=
operator.Take this example if expression from SE-0380:
on develop, this is unexpectedly re-indented to:
Since this is the formatting used in SE-0380, it seems like this will be a common preferred way to format these sorts of conditional assignment expressions.
The text was updated successfully, but these errors were encountered: