If the opening brace of a function is on a separate line, then when partially formatting the body of the function with --file-lines the opening brace can be moved to the previous line, even if neither of those lines were selected.
Summary
Consider the following file test.rs which defines a function where the opening brace of the function is on its own line:
fn main()
{
println!("weeeeee");
println!("weeeeee");
println!("weeeeee");
}
I would like to use --file-lines '[{"file":"test.rs","range":[5,5]}]' to format just the last line of the function.
Expected Behavior
Only the selected line is formatted:
fn main()
{
println!("weeeeee");
println!("weeeeee");
println!("weeeeee");
}
Actual Behavior
The selected line, the preceding line, and the first two lines of the function are modified:
fn main() {
println!("weeeeee");
println!("weeeeee");
println!("weeeeee");
}
I have a separate issue up for the fact that line 4 is also modified (#6863), this issue is meant to focus on the fact that lines 1-2 are modified even though they are outside the selected range.
Configuration
rustfmt cli options used:
rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[5,5]}]' test.rs
If the opening brace of a function is on a separate line, then when partially formatting the body of the function with
--file-linesthe opening brace can be moved to the previous line, even if neither of those lines were selected.Summary
Consider the following file
test.rswhich defines a function where the opening brace of the function is on its own line:I would like to use
--file-lines '[{"file":"test.rs","range":[5,5]}]'to format just the last line of the function.Expected Behavior
Only the selected line is formatted:
Actual Behavior
The selected line, the preceding line, and the first two lines of the function are modified:
I have a separate issue up for the fact that line 4 is also modified (#6863), this issue is meant to focus on the fact that lines 1-2 are modified even though they are outside the selected range.
Configuration
rustfmtcli options used:rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[5,5]}]' test.rs