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

Sometimes splits on module resolution (::) #31

Open
bbugh opened this issue Sep 11, 2023 · 1 comment
Open

Sometimes splits on module resolution (::) #31

bbugh opened this issue Sep 11, 2023 · 1 comment

Comments

@bbugh
Copy link

bbugh commented Sep 11, 2023

Input code

// Default rustfmt 
    let data = 
        fs::read_to_string(&json_path).unwrap_or_else(|_| panic!("Unable to read {:?}", json_path));

Output code

// prettier-plugin-rust
    let data = fs
        ::read_to_string(&json_path)
        .unwrap_or_else(|_| panic!("Unable to read {:?}", json_path));

Additional context

fs::read_to_string shouldn't be broken across lines, it's a single qualified value.

It only does this sometimes, not in a way that I can reproduce. There's many other cases in my code where it didn't do this, for example:

                    DefaultMakeSpan::new().include_headers(true).level(tracing::Level::DEBUG)
@jinxdash
Copy link
Owner

jinxdash commented Sep 18, 2023

Thanks for the report!
This is intended behavior. :: is intended to sometimes break to improve readability, this is based on conditions similar to breaking chain calls.

All styling decisions in this formatter are acquired from prettier core, and I'm reluctant to make changes to it

With that said, there are exceptions in core to never break on a few widely used javascript-specific names such as it.<method> from testing libraries. Maybe fs should get that treatment, I'm not sure.

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

2 participants