Fix newline after dbg formatting

This commit is contained in:
Joshua Warner 2024-12-01 18:05:37 -08:00
parent 4a0dce714b
commit 8c25c9aaf7
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
7 changed files with 70 additions and 1 deletions

View file

@ -1387,10 +1387,26 @@ fn fmt_dbg_stmt<'a>(
)
.format_with_options(buf, parens, Newlines::Yes, indent);
let cont_lifted = expr_lift_spaces(Parens::NotNeeded, buf.text.bump(), &continuation.value);
if !cont_lifted.before.is_empty() {
format_spaces(buf, cont_lifted.before, Newlines::Yes, indent);
}
// Always put a newline after the `dbg` line(s)
buf.ensure_ends_with_newline();
continuation.format(buf, indent);
format_expr_only(
&cont_lifted.item,
buf,
Parens::NotNeeded,
Newlines::Yes,
indent,
);
if !cont_lifted.after.is_empty() {
format_spaces(buf, cont_lifted.after, Newlines::Yes, indent);
}
}
fn fmt_return<'a>(

View file

@ -0,0 +1,46 @@
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-8,
],
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-2 RecordDestructure(
[],
),
@3-8 Apply(
@3-6 Dbg,
[
@7-8 Var {
module_name: "",
ident: "l",
},
],
Space,
),
),
],
},
@10-11 SpaceBefore(
Var {
module_name: "",
ident: "n",
},
[
LineComment(
"",
),
],
),
)

View file

@ -331,6 +331,7 @@ mod test_snapshots {
pass/closure_with_underscores.expr,
pass/comma_prefixed_indented_record.expr,
pass/comment_after_annotation.expr,
pass/comment_after_dbg_in_empty_record_assignment.expr,
pass/comment_after_def.moduledefs,
pass/comment_after_expr_in_parens.expr,
pass/comment_after_op.expr,