Correct handling of binop with SpaceAfter in a Body def

This commit is contained in:
Joshua Warner 2025-01-14 20:48:23 -08:00
parent 51f2cdccf7
commit 7f1b3449a6
10 changed files with 172 additions and 5 deletions

View file

@ -1062,7 +1062,7 @@ pub fn fmt_body<'a>(buf: &mut Buf, pattern: &'a Pattern<'a>, body: &'a Expr<'a>,
buf.ensure_ends_with_newline();
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
}
Expr::Defs(..) | Expr::BinOps(_, _) => {
Expr::Defs(..) | Expr::BinOps(..) | Expr::SpaceAfter(&Expr::BinOps(..), _) => {
// Binop chains always get a newline. Otherwise you can have things like:
//
// something = foo

View file

@ -1488,7 +1488,6 @@ fn fmt_binops<'a>(
buf: &mut Buf,
lefts: &'a [(Loc<Expr<'a>>, Loc<BinOp>)],
loc_right_side: &'a Loc<Expr<'a>>,
indent: u16,
) {
let is_multiline = loc_right_side.value.is_multiline()