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 #335
Comments
<img src="https://avatars.githubusercontent.com/u/17034?v=3" align="left" width="48" height="48"hspace="10"> Comment by kevmoo Added Area-Formatter, Triaged labels. |
<img src="https://avatars.githubusercontent.com/u/8616782?v=3" align="left" width="48" height="48"hspace="10"> Comment by clayberg Set owner to @pq. |
<img src="https://avatars.githubusercontent.com/u/67586?v=3" align="left" width="48" height="48"hspace="10"> Comment by pq Removed this from the 1.3 milestone. |
<img src="https://avatars.githubusercontent.com/u/67586?v=3" align="left" width="48" height="48"hspace="10"> Comment by 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 dart-lang/sdk@3edb0ef, please re-open this bug and include the expected output. Again thanks for the feedback! Added AssumedStale label. |
<img src="https://avatars.githubusercontent.com/u/648527?v=3" align="left" width="48" height="48"hspace="10"> Comment 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 ':'. |
<img src="https://avatars.githubusercontent.com/u/67586?v=3" align="left" width="48" height="48"hspace="10"> Comment by pq 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. |
<img src="https://avatars.githubusercontent.com/u/2049220?v=3" align="left" width="48" height="48"hspace="10"> Comment by 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() |
<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent +1 what Siggy said (though personally I always wrap them). One nit: the ":" should be indented +4, like: Classname.three() |
<img src="https://avatars.githubusercontent.com/u/648527?v=3" align="left" width="48" height="48"hspace="10"> Comment by Fox32 Then the guide should be updated, as it states: "DO format constructor initialization lists with each field on its own line." |
<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl Removed this from the 1.4 milestone. |
<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl Removed this from the 1.5 milestone. |
<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl Removed this from the 1.6 milestone. |
<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl Removed Oldschool-Milestone-1.6 label. |
<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent Added AssumedStale label. |
<img src="https://avatars.githubusercontent.com/u/648527?v=3" align="left" width="96" height="96"hspace="10"> Issue by Fox32
Originally opened as dart-lang/sdk#17514
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: