Skip to content

Range formatting with file-lines is different depending on LF/CRLF #3494

@Xanewok

Description

@Xanewok

Reproduction:

pub fn main()
{
let world1 = "world"; println!("Hello, {}!", world1);
let world2 = "world"; println!("Hello, {}!", world2);
let world3 = "world"; println!("Hello, {}!", world3);
    }

Using the following invocation:

rustfmt --file-lines '[{"file":"$FILE", "range": [2,3]}]' $FILE --unstable-features

Results

If the text has LF as EOL:

pub fn main() {
    let world1 = "world";
    println!("Hello, {}!", world1);
let world2 = "world"; println!("Hello, {}!", world2);
let world3 = "world"; println!("Hello, {}!", world3);
    }

If the text has CRLF as EOL:

pub fn main() {
    let world1 = "world";
    println!("Hello, {}!", world1);
    let world2 = "world"; println!("Hello, {}!", world2);
let world3 = "world"; println!("Hello, {}!", world3);
    }

@scampi do you have any idea what may cause that? I'd be willing to look into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.only-with-optionrequires a non-default option value to reproducep-highpoor-formatting

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions