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

comment_width is ignored when bigger than max_width #2939

Closed
konstin opened this issue Aug 19, 2018 · 2 comments
Closed

comment_width is ignored when bigger than max_width #2939

konstin opened this issue Aug 19, 2018 · 2 comments
Labels
only-with-option requires a non-default option value to reproduce poor-formatting

Comments

@konstin
Copy link

konstin commented Aug 19, 2018

When comment_width is set to a larger value than max_width, comment_width is still bound by max_width. Take the following project:

rustfmt.toml

wrap_comments = true
comment_width = 1234

main.rs

/// Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore
fn main() {
    println!("Hello, world!");
}

The doc comment is fine according to the comment width, but still wrapped as it is longer than 100 characters:

/// Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt
/// ut labore
fn main() {
    println!("Hello, world!");
}

The use case I have for this is that I want to format only the code samples in the comments, but not comments itself. (I'm working on pyo3 which has lots of wide doc comments that are wrapped incorrectly with the default comment_width, but which also have many code samples that should be properly formatted.)

rustfmt -V: rustfmt 0.99.2-nightly (5c9a2b6 2018-08-07)

@nrc nrc added poor-formatting only-with-option requires a non-default option value to reproduce labels Aug 22, 2018
@scampi
Copy link
Contributor

scampi commented Nov 8, 2018

I think if you remove wrap_comments and use the option format_doc_comments, you get what you want: it formats the doc test but leaves the comment alone.

@scampi
Copy link
Contributor

scampi commented May 16, 2019

fixed by #3535

@scampi scampi closed this as completed May 16, 2019
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

No branches or pull requests

3 participants