fix: #6520, move comment above line if it would cross out the type in… #6577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… a function arg.
fixes #6520
A bit unsure about this one.
The problem is that if you have a comment that spans to the end of the line, then pushing the
ty_str
after it will make thatty_str
part of the comment.It's similar to this #2976 except isolates comments that do not close themselves.
There's some nuance here, since the decision has to be made where to put the comment. Putting it on top is the simplest, putting it last on the line would require making sure that nothing follows the comment.
Lastly, checking the comment style processes the span again, which is why that's only done conditionally if there is some comment there, so it shouldn't hit most cases. The alternative is a bigger refactor where either the comment style is identified before being passed down to
identify_comment
, or that metadata is propagated up from the caller. Neither of those options seemed nice.