Skip to content
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

Closed
DartBot opened this issue Feb 17, 2014 · 13 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Feb 17, 2014

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.

@kevmoo
Copy link
Member

kevmoo commented Feb 17, 2014

Added Area-Formatter, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented Feb 17, 2014

Changed the title to: "If wrapping is required, avoid breaking within statements unless it increases the total number of lines created".

@pq
Copy link
Member

pq commented Feb 20, 2014

Thanks for the report. So we're on the same page, are you proposing the following in your example?:

void main() {
  if (true) throw new
      FormatError('This is my Stupid long error. Do you like it?');
}


Set owner to @pq.
Added this to the 1.3 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@DartBot
Copy link
Author

DartBot commented Feb 21, 2014

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)

@clayberg
Copy link

Removed Type-Defect label.
Added Type-Enhancement label.

@pq
Copy link
Member

pq commented Apr 9, 2014

Removed this from the 1.3 milestone.
Added this to the 1.4 milestone.

@kevmoo
Copy link
Member

kevmoo commented Apr 27, 2014

Marked this as blocking #16327.

@kasperl
Copy link

kasperl commented May 8, 2014

Removed this from the 1.4 milestone.
Added this to the 1.5 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the 1.5 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-1.6 label.

@munificent
Copy link
Member

Added AssumedStale label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/dart_style#321.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants