Skip to content

Feature request: wrap_comments should wrap even if URL is detected in comment #6459

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

Closed
leon-xd opened this issue Jan 28, 2025 · 2 comments
Closed

Comments

@leon-xd
Copy link

leon-xd commented Jan 28, 2025

Hello! I recently ran into an issue where comments weren't wrapping if there was a URL in the comment; after looking deeper into the documentation, turns out this is expected behavior!

From the documentation:

Note that no wrapping will happen if:

  1. The comment is the start of a markdown header doc comment
  2. An URL was found in the comment

A previous discussion on this can be found at #5634, there seemed to be no conclusive action on this other than adding this behavior to the documentation.

Adding this by default or having some sort of additional configuration set in rustfmt.toml to enable this would be great.

Thanks!

@ytmimi
Copy link
Contributor

ytmimi commented Jan 28, 2025

This behavior is intentional, and as mentioned in #5634 (comment), this behavior helps prevent other issues. If you'd like you can introduce line breaks manually, and rustfmt shouldn't modify them.

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2025
@wmmc88
Copy link

wmmc88 commented Jan 29, 2025

@ytmimi I see that wrap_comments no functioning when a URL is detected is the current intended behavior, but I think the OP is asking for wrap_comments to still wrap the block, but just don't break the URL across multiple lines(ie. if the url puts it over the width limit, the line break should be inserted before the url. Would a behaviour change like that be accepted?

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

No branches or pull requests

3 participants