Fix else spacing

This commit is contained in:
Joshua Warner 2025-01-11 10:32:53 -08:00
parent 6b08f42d02
commit 1cc97fcfa7
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 50 additions and 2 deletions

View file

@ -1915,6 +1915,7 @@ fn fmt_if<'a>(
buf.indent(indent);
if i > 0 {
buf.ensure_ends_with_whitespace();
buf.push_str("else");
buf.spaces(1);
}
@ -1934,12 +1935,12 @@ fn fmt_if<'a>(
fmt_comments_only(buf, then.after.iter(), NewlineAt::Bottom, return_indent);
buf.ensure_ends_with_newline();
} else {
buf.push_str("");
buf.spaces(1);
loc_then.format(buf, return_indent);
}
}
buf.ensure_ends_with_whitespace();
if indented_else {
buf.indent(indent + INDENT);
buf.push_str("else");
@ -1951,7 +1952,7 @@ fn fmt_if<'a>(
buf.newline();
} else {
buf.indent(indent);
buf.push_str(" else");
buf.push_str("else");
buf.spaces(1);
}
let indent = if indented_else { indent } else { return_indent };