-
Notifications
You must be signed in to change notification settings - Fork 908
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
Determine when new comment lines are needed for itemized blocks #5097
Conversation
Nice! I think this is probably the right route to go, though out of an abundance of caution, could you add some additional test cases (above and beyond what you already have) which will actually hit the width boundaries and force a wrap? That should be doable either via some longer inputs (and/or with added indentation levels/nested items/etc.), or by setting |
Sure thing. I'll include some more tests for this PR! |
33260a1
to
b6d6a2e
Compare
@calebcartwright I've gone ahead and added the additional test cases that force the comments to wrap. let me know if there's anything else you feel we should be testing to round out the PR. |
One case where the proposed changes would be problematic would be when an itemized block opens with an empty comment line, e.g. (note no trailing spaces after the first opener) //
// - some itemized block 1
// - some itemized block 2 Haven't dug into the cause, but that input with the proposed changes would result in the first line getting stripped, and the opening space in the first item getting dropped, e.g. //- some itemized block 1
// - some itemized block 2 So we'll need to iterate on this a bit more |
I went back and took a look at this. There was a logical bug in |
Looks good, thanks for following up. My last ask (perhaps more of a question than a request) is whether it'd be worthwhile to include any of these tests but in the default mode ( |
Added |
Fixes 5088 Previously, rustfmt would add a new comment line anytime it reformatted an itemized block within a comment when ``wrap_comments=true``. This would lead to rustfmt adding empty comments with trailing whitespace. Now, new comment lines are only added if the original comment spanned multiple lines, if the comment needs to be wrapped, or if the comment originally started with an empty comment line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #5088
Previously,
rustfmt
would add a new comment line anytime it reformattedan itemized block within a comment. This would lead to
rustfmt
addingempty comments with trailing whitespace.
Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.