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

Fix comments on separators and handling message literals and compound strings in options #3325

Merged
merged 8 commits into from
Sep 18, 2024

Conversation

doriable
Copy link
Member

This fixes some issues in the formatter for handling trailing comments
on separators (, and ;) in message literals. These comments are added
to the element if the element itself did not have trailing comments. However,
the comments that were added to message and array literal elements are
"left behind" because they are not being handled. This PR adds logic that
handles these comments similar to how comments on separators are handled --
it checks array and message literals for any trailing comments that may have been
added in this manner and adds them to closing brackets, if the closing brackets
did not have comments originally. Tests have been added for these cases.

In the process of testing, we also found an additional bug, where empty message
literals were not being handled as compact messages and compound strings in
options were not being written with their ends in-line for trailing commas.

Fixes #3322

Copy link
Contributor

github-actions bot commented Sep 16, 2024

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 16, 2024, 9:54 PM

@bufdev
Copy link
Member

bufdev commented Sep 16, 2024

Needs changelog

@bufdev bufdev merged commit 4e2a48f into main Sep 18, 2024
11 checks passed
@bufdev bufdev deleted the separatorComments branch September 18, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Buf format deletes inline comments in some cases
3 participants