mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Fix when branches to use lifting as well
This commit is contained in:
parent
e068ae6b5a
commit
c4077dc971
5 changed files with 62 additions and 19 deletions
|
@ -1605,27 +1605,25 @@ fn fmt_when<'a>(
|
|||
|
||||
let inner_indent = line_indent + INDENT;
|
||||
|
||||
match expr.value {
|
||||
Expr::SpaceBefore(nested, spaces) => {
|
||||
fmt_spaces_no_blank_lines(buf, spaces.iter(), inner_indent);
|
||||
let expr = expr_lift_spaces(Parens::NotNeeded, buf.text.bump(), &expr.value);
|
||||
fmt_spaces_no_blank_lines(buf, expr.before.iter(), inner_indent);
|
||||
if is_multiline_expr {
|
||||
buf.ensure_ends_with_newline();
|
||||
} else {
|
||||
buf.spaces(1);
|
||||
}
|
||||
|
||||
if is_multiline_expr {
|
||||
buf.ensure_ends_with_newline();
|
||||
} else {
|
||||
buf.spaces(1);
|
||||
}
|
||||
// expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, inner_indent);
|
||||
format_expr_only(
|
||||
&expr.item,
|
||||
buf,
|
||||
Parens::NotNeeded,
|
||||
Newlines::Yes,
|
||||
inner_indent,
|
||||
);
|
||||
|
||||
nested.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, inner_indent);
|
||||
}
|
||||
_ => {
|
||||
if is_multiline_expr {
|
||||
buf.ensure_ends_with_newline();
|
||||
} else {
|
||||
buf.spaces(1);
|
||||
}
|
||||
|
||||
expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, inner_indent);
|
||||
}
|
||||
if !expr.after.is_empty() {
|
||||
format_spaces(buf, expr.after, Newlines::Yes, inner_indent);
|
||||
}
|
||||
|
||||
prev_branch_was_multiline = is_multiline_expr || is_multiline_patterns;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue