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

Don't insert trailing commas over the max width #473

Closed
wants to merge 1 commit into from

Conversation

nreid260
Copy link
Contributor

@nreid260 nreid260 commented Jun 4, 2024

Closes #472

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 4, 2024
@nreid260
Copy link
Contributor Author

nreid260 commented Jun 4, 2024

@hick209

| )
| bar(
| someArg,
| exactlyAtMaaax
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that was @Rawa was referring to in #472?

What I understood was that the comma should have forced the line break, respecting the line max width option, which for this particular case here, where we cannot respect it, the comma would still be included.

@Rawa, is my understanding correct or were you also thinking something along the lines of what @nreid260 did here?

Copy link
Contributor Author

@nreid260 nreid260 Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an ideal solution, more of a hack to mitigate complaints. I can't think of an efficient algorithm for:

  • Remove unnecessary trailing commas
  • Insert line breaks between items in long lists
    • Insert trailing commas in broken lists

It's the last part that's being reported as a bug, because when the list item is exactly 100 columns, the trailing comma is inserted into column 101. Shorter items put the comma within bounds, longer items get wrapped during formatting.

Running prettyPrint twice would be slow, and also makes tests hard to debug.

The key thing is that tailing commas are still 100% automated.

@hick209
Copy link
Contributor

hick209 commented Jun 5, 2024

TBH I'd prefer to have the code as is vs this modification here.

I'm happy to hear arguments countering that though, but if you don't have any, just keep this PR closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google style with trailing comma does not use maxWidth correctly
3 participants