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

wrap_comments breaks links with long URL #3787

Closed
AlephAlpha opened this issue Sep 8, 2019 · 1 comment · Fixed by #3809
Closed

wrap_comments breaks links with long URL #3787

AlephAlpha opened this issue Sep 8, 2019 · 1 comment · Fixed by #3809
Labels
only-with-option requires a non-default option value to reproduce poor-formatting

Comments

@AlephAlpha
Copy link

With wrap_comments = true, the following code:

//! * [This is a link with a very loooooooooooooooooooooooooooooooooooooooooong URL.](https://example.com/This/is/a/link/with/a/very/loooooooooooooooooooooooooooooooooooooooooong/URL)
fn main() {
    println!("Hello, world!");
}

will be formatted as:

//! 
//! * [This is a link with a very loooooooooooooooooooooooooooooooooooooooooong
//!   URL.](https://example.com/This/is/a/link/with/a/very/
//!   loooooooooooooooooooooooooooooooooooooooooong/URL)
fn main() {
    println!("Hello, world!");
}

The URL is broken into two lines.

It seems that this only happens in lists.

@Juici
Copy link

Juici commented Jan 9, 2020

This is still an issue.

When running rustfmt with wrap_comments = true, markdown links get chopped in half thus breaking them.

Version information:

rustfmt 1.4.11-nightly (1838235 2019-12-03)
rustc 1.42.0-nightly (859764425 2020-01-07)
cargo 1.42.0-nightly (6e1ca924a 2020-01-06)
rustup 1.21.1 (7832b2ebe 2019-12-20)
Contents of rustfmt.toml
		max_width = 100
		hard_tabs = false
		tab_spaces = 4
		wrap_comments = true
		comment_width = 80
		normalize_comments = true
		merge_imports = false
		reorder_imports = true
		reorder_modules = true
		reorder_impl_items = true
		trailing_semicolon = true
		trailing_comma = "Vertical"
		match_block_trailing_comma = false
		blank_lines_upper_bound = 1
		blank_lines_lower_bound = 0
		merge_derives = true
		use_try_shorthand = true
		unstable_features = true
		edition = "2018"
	

Contents of rustfmt.toml relating to comments:

max_width = 100
wrap_comments = true
comment_width = 80
normalize_comments = true
unstable_features = true

edition = "2018"

Output with --check flag:

     /// Bots as well as users with the permission [`MANAGE_MESSAGES`] or
     /// [`MANAGE_CHANNEL`], are unaffected.
     ///
-    /// [`MANAGE_MESSAGES`]: ../permissions/struct.Permissions.html#associatedconstant.MANAGE_MESSAGES
-    /// [`MANAGE_CHANNEL`]: ../permissions/struct.Permissions.html#associatedconstant.MANAGE_CHANNEL
+    /// [`MANAGE_MESSAGES`]:
+    /// ../permissions/struct.Permissions.html#associatedconstant.
+    /// MANAGE_MESSAGES [`MANAGE_CHANNEL`]:
+    /// ../permissions/struct.Permissions.html#associatedconstant.MANAGE_CHANNEL
     #[serde(default, rename = "rate_limit_per_user")]
     pub rate_limit: u16,
     /// The ID of the parent category of the channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
only-with-option requires a non-default option value to reproduce poor-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants