-
Notifications
You must be signed in to change notification settings - Fork 125
Complex nested cascades sometimes extend past line length unnecessarily #811
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
Labels
Comments
https://github.com/dart-lang/dart_style/wiki/FAQ#why-did-the-formatter-only-format-some-of-my-code You might want to break this up into multiple expressions. |
I'm going to keep this open so we can use it as a regression test if we optimize how cascades are formatted. |
Here's another (sanitized) example: aaaa() {
{
{
{
aaaaa aaaaa = AaaAaaaa.aaaaaaa().aaaaaaa((a) => a
..aaaaAaaaa
.aaaaaaaaaaaAaAaaa[AaaaAaaaaaaaaaAaaa_Aaaa.AAA_AAAAAAAAAAA_AAAAA_AAAAAAA.aaaa] =
aaaa
..aaaaAaaaa.aaaaaaaaaaaAaAaaa[AaaaAaaaaaaaaaAaaa_Aaaa
.AAA_AAAAAAAAAAA_AAAAAAAA_AAAA_AAAAAAAAA.aaaa] = aaaa
..aaaaAaaaa.aaaaaaaaaaaAaAaaa[AaaaAaaaaaaaaaAaaa_Aaaa
.AAA_AAAAAAAAAAA_AAAAAAA_AAAA_AAAAAAAAA.aaaa] = aaaa
..aaaaAaaaa.aaaaaaaaaaaAaAaaa[AaaaAaaaaaaaaaAaaa_Aaaa
.AAA_AAAAAAAAAAA_AAAAAA_AAAAAAA_AAA_AAAAAAAAAAA_AAAAA.aaaa] = aaaa
..aaaaaaaaAaaaaaAaaaa.aaaaaaa(AaaaaaaaAaaaaaAaaaaAaaaa.aaaaaaa())
..aaaaaaaaAaaaa.aaaaaaaa =
(Aaaaaaaa()..aaaaaaaaAaaa = (AaaaaaaaAaaa()..aaAaaaaaa = aaaaa)));
}
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code is formatted by dartfmt as shown. Note that the last line of actual code is longer than 80 characters.
The output I'd expect is more like:
In other words, I'd expect the final when().thenRespond() chain to wrap more like the first one does.
There's some interesting interactions going on within this expression which are hard to figure out from a black-box perspective. Simplifying the above code any more than this (for example, removing any of the when() calls) fixes the issue.
The text was updated successfully, but these errors were encountered: