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
If wrapping is required, avoid breaking within statements unless it increases the total number of lines created #16897
Comments
Added Area-Formatter, Triaged labels. |
Changed the title to: "If wrapping is required, avoid breaking within statements unless it increases the total number of lines created". |
Thanks for the report. So we're on the same page, are you proposing the following in your example?: void main() { Set owner to @pq. |
This comment was originally written by @butlermatt Sorry for the delay. Yes, if there is enough room, I'd prefer the example you reference. However I suppose it would really depend on how long the class name + argument are (eg: if the "FormatError('This is my...')", plus indenting, is longer than 80 (or other specified) character line length, then I can see using the current behaviour. If however the class name + argument + indentation is less than line length limit then prefer moving the class name (as shown in #3) |
Removed Type-Defect label. |
Marked this as blocking #16327. |
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#321. |
This issue was originally filed by @butlermatt
Take the sample program below:
void main() {
if (true)
throw new FormatError('This is my Stupid long error. Do you like it?');
}
Run through dartfmt. Output is:
void main() {
if (true) throw new FormatError(
'This is my Stupid long error. Do you like it?');
}
I think if a long line is part of the constructor, if possible dartfmt should at the least move the class name to the next line (if possible) not just the argument.
That said, I'd prefer the output of my original with the throw statement also on the following line, which is achieved by wrapping the if block in curly braces.
The text was updated successfully, but these errors were encountered: