Fix formatting of body when pattern is multi-line

This commit is contained in:
Joshua Warner 2024-12-15 17:56:15 -08:00
parent 01dda78271
commit 7b09b15dea
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 88 additions and 0 deletions

View file

@ -1009,6 +1009,7 @@ pub fn fmt_body<'a>(
} else {
buf.spaces(1);
}
let indent = buf.cur_line_indent();
buf.push_str("=");
let body = expr_lift_and_lower(Parens::NotNeeded, buf.text.bump(), body);

View file

@ -0,0 +1,78 @@
@0-14 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-12,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@0-7 RecordDestructure(
[
@1-6 OptionalField(
"e",
@3-6 Apply(
@3-4 Var {
module_name: "",
ident: "f",
},
[
@5-6 SpaceBefore(
Num(
"4",
),
[
Newline,
],
),
],
Space,
),
),
],
),
@8-12 Apply(
@8-9 Var {
module_name: "",
ident: "f",
},
[
@11-12 SpaceBefore(
Var {
module_name: "",
ident: "e",
},
[
Newline,
],
),
],
Space,
),
),
],
},
@13-14 SpaceBefore(
Var {
module_name: "",
ident: "r",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -574,6 +574,7 @@ mod test_snapshots {
pass/ops_with_newlines.expr,
pass/opt_field_newline_in_pat.expr,
pass/opt_field_newline_in_ty.expr,
pass/opt_record_field_pat_assign.expr,
pass/outdented_app_with_record.expr,
pass/outdented_colon_in_record.expr,
pass/outdented_list.expr,