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
Formatter problem with initializer list #17514
Comments
Added Area-Formatter, Triaged labels. |
Set owner to @pq. |
Thanks for the report. I just landed a related fix that might address this (https://codereview.chromium.org/231743002/). The current behavior formats this: class Vector3 { to: class Vector3 { If you're still seeing surprising results after r34893, please re-open this bug and include the expected output. Again thanks for the feedback! Added AssumedStale label. |
This comment was originally written by @Fox32 Maybe the formatting rule should be more specific in the Dart Style Guide as I assumed that it is required to always do a new line before the ':'. |
Ah, wait. Good catch. I think we agreed that a single initializer could live on a single line but now I'm not sure. Anyway, either this or the style guide need updating. :) Bob, Siggi: thoughts? cc @sigmundch. |
Yes - inline initializers are allowed, and are not necessarily limited to just one. Only when you exceed the 80 column limit we need to break on the ":". I believe all of these are valid (correctly formatted) as is: class Classname { Classname.one() : a = 1, b = 2, c = 3; Classname.two() : a = 1, b = 2, c = 3 { Classname.three() Classname.three() |
+1 what Siggy said (though personally I always wrap them). One nit: the ":" should be indented +4, like: Classname.three() |
This comment was originally written by @Fox32 Then the guide should be updated, as it states: "DO format constructor initialization lists with each field on its own line." |
Removed this from the 1.6 milestone. |
Removed Oldschool-Milestone-1.6 label. |
Added AssumedStale label. |
This issue has been moved to dart-lang/dart_style#335. |
This issue was originally filed by @Fox32
Dart formatter is unable to format this code correctly:
Vector3(double x_, double y_, double z_): storage = new Float32List(3) {
setValues(x_, y_, z_);
}
If I give a hint by adding a line break before the ":", everything works fine. If I add a space instead, the space is removed.
Dart Editor version 1.3.0.dev_03_02 (DEV)
Dart SDK version 1.3.0-dev.3.2
The text was updated successfully, but these errors were encountered: