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

Split before adjacent strings pushes string to the right #409

Closed
MilanLi opened this issue Aug 31, 2015 · 3 comments
Closed

Split before adjacent strings pushes string to the right #409

MilanLi opened this issue Aug 31, 2015 · 3 comments

Comments

@MilanLi
Copy link

MilanLi commented Aug 31, 2015

Before formatting:

it('should complete with an error if the name or website is null or both '
    'are unchanged', async(() {
  ICouldDoAnything();
}));

After formatting:

it(
    'should complete with an error if the name or website is null or both '        //<------ exceeds 80 chars limit
    'are unchanged', async(() {
  ICouldDoAnything();
}));
@munificent munificent changed the title dartfmt does not always keep line limits to 80 chars Split before adjacent strings pushes string to the right Nov 17, 2015
@maxwellpeterson-wf
Copy link

This is a common issue we see when writing unit tests with the test package as well.

@srawlins
Copy link
Member

Since the formatter does not split string literals, there are many ways in which a string literal is "pushed to the right" such that it exists past 80 characters. Not much to do about that aside from splitting string literals.

But note, in the case summarized at the top, the new tall style formatting (in its WIP form) will break before the string literal, likely moving it left rather than right.

@munificent
Copy link
Member

Right. The forthcoming tall style gives you:

it(
  'should complete with an error if the name or website is null or both '
  'are unchanged',
  async(() {
    ICouldDoAnything();
  }),
);

As @srawlins says, the formatter doesn't split strings so it may still push a long string past the end of the page, but in this case, it does so less and has the output I expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants