mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
formatter: support removing blank lines between when branches if all branches are single line
This commit is contained in:
parent
7def844302
commit
802422e6f4
2 changed files with 7 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue