Open
Description
With vscode extension rust-analyzer
, the (visual) line width in editor might not the same as the width in text file.
e.g.
fn f(very_very_very_very_long_arg_1: i32, very_very_very_very_long_arg_2: i32) {}
fn main() {
f("1".parse().expect("true"), "2".parse().expect("true")); // what rustfmt see
}
with rust-analyzer it would be rendered as
fn main() {
f(very_very_very_very_long_arg_1: "1".parse().expect("true"), very_very...: "2".parse().expect("true")); // what we see
}
which is much longer.
The question here is not that rustfmt would not turn this f("1".parse().expect("true"), "2".parse().expect("true"));
into vertical format, it is about rustfmt
would shrink my vertical formatting version into oneline.
// I write it vertically, after `cargo fmt` it would be forced be into one line
fn main() {
f(
"1".parse().expect("true"),
"2".parse().expect("true"),
);
}
I think we should add an option like no_force_same_line
that rustfmt
would only break long line but not combine lines, so that when I explicitly write vertical formatting code, rustfmt would leave it as is.