-
Notifications
You must be signed in to change notification settings - Fork 125
extra space needed before :
with single initializer
#792
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
Comments
I'm not sure if we want to do this one, unfortunately. In general, dartfmt only does indentation at the beginning of lines and doesn't otherwise try to align intra-line content. (See #508 for a bit more discussion.) I worry that if we take this change then users will file bugs asking why there's an extra space before the |
(Oops, didn't mean to click "Close".) |
It already adds spaces for initializer list with several entries: class A {
final a;
const A(
p,
) : a = p,
super();
} This absence of space makes the split indentation the only place with an inconsistant indentation. class A {
final a;
const A.c1(
p,
) : super(
a: p,
);
// ^^ WAT
// with several elements in initializer list, no problem
const A.c2(
p,
) : a = p,
super(
a: p,
);
} |
Yeah, I agonized over that one. :-/ |
I don't think there's an ideal way to format constructor initializer lists. They're just pretty syntactically weird. If we don't do extra padding before the I spent a lot of time inspecting how hand-formatted initializer lists in the Flutter repo are styled. It turns out they are pretty inconsistent, but I aimed to follow the most common styles I could see there. That was to not do padding and accept that the initializer list might get shifted if you change whether or not the constructor has optional parameters. The style isn't perfect, but I think it's about as good as I can get it. With the forthcoming tall style, you get: class PestoStyle extends TextStyle {
const PestoStyle({
double fontSize = 12.0, // comment to force split
}) : super(
inherit: false, // comment to force split
);
} And: class A {
A(
a, // comment to force split
) : parameter =
"some very very very very very very very very very long param";
} And: class A {
final a;
const A.c1(
p, // comment to force split
) : super(
a: p, // comment to force split
);
} |
Actual:
expected:
Same issue when the single initializer splits:
Actual:
Expected:
The text was updated successfully, but these errors were encountered: