formatter: support removing blank lines between when branches if all branches are single line

This commit is contained in:
Sean Hagstrom 2022-05-19 08:40:59 +01:00
parent 7def844302
commit 802422e6f4
No known key found for this signature in database
GPG key ID: AA9814E95B301A5C
2 changed files with 7 additions and 3 deletions

View file

@ -636,6 +636,9 @@ fn fmt_when<'a, 'buf>(
indent: u16,
) {
let is_multiline_condition = loc_condition.is_multiline();
let has_multiline_branches = branches
.iter()
.any(|branch| is_when_patterns_multiline(branch) || branch.value.is_multiline());
buf.indent(indent);
buf.push_str(
"\
@ -741,7 +744,9 @@ fn fmt_when<'a, 'buf>(
if it.peek().is_some() {
buf.newline();
buf.newline();
if has_multiline_branches {
buf.newline();
}
}
}
}