Fix pnc args multiine in the presence of final comments

This commit is contained in:
Joshua Warner 2025-01-08 21:25:39 -08:00
parent 158691fb27
commit 0438c17503
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 40 additions and 5 deletions

View file

@ -521,10 +521,7 @@ pub fn expr_is_multiline(me: &Expr<'_>, comments_only: bool) -> bool {
.any(|loc_arg| expr_is_multiline(&loc_arg.value, comments_only))
}
Expr::PncApply(loc_expr, args) => {
expr_is_multiline(&loc_expr.value, comments_only)
|| args
.iter()
.any(|loc_arg| expr_is_multiline(&loc_arg.value, comments_only))
expr_is_multiline(&loc_expr.value, comments_only) || is_collection_multiline(args)
}
Expr::DbgStmt { .. } => true,

View file

@ -0,0 +1,31 @@
@0-7 SpaceAfter(
Apply(
@0-6 PncApply(
@0-1 Var {
module_name: "",
ident: "i",
},
Collection {
items: [
@2-3 Var {
module_name: "",
ident: "i",
},
],
final_comments: [
Newline,
],
},
),
[
@6-7 Var {
module_name: "",
ident: "t",
},
],
Space,
),
[
Newline,
],
)

View file

@ -189,8 +189,8 @@ mod test_snapshots {
fail/ability_demands_not_indented_with_first.expr,
fail/ability_first_demand_not_indented_enough.expr,
fail/ability_non_signature_expression.expr,
fail/all_the_bangs.expr,
fail/alias_or_opaque_fail.expr,
fail/all_the_bangs.expr,
fail/bound_variable.expr,
fail/comment_with_tab.expr,
fail/d_assign_return_bang.expr,
@ -631,6 +631,7 @@ mod test_snapshots {
pass/pizza_question.moduledefs,
pass/plus_if.expr,
pass/plus_when.expr,
pass/pnc_apply_comment_after_newline.expr,
pass/pos_inf_float.expr,
pass/positive_float.expr,
pass/positive_int.expr,