Merge pull request #2112 from rtfeldman/joshuawarner32/fix-defs-indenting

Fix fmt_spaces indenting in the context of 3 or more newlines
This commit is contained in:
Richard Feldman 2021-12-01 21:58:58 -05:00 committed by GitHub
commit 23fda0819f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 6 deletions

View file

@ -596,8 +596,7 @@ fn fmt_when<'a>(
);
for when_pattern in rest {
if is_multiline {
buf.push_str("\n");
add_spaces(buf, indent + INDENT);
newline(buf, indent + INDENT);
buf.push_str("| ");
} else {
buf.push_str(" | ");
@ -610,9 +609,9 @@ fn fmt_when<'a>(
guard_expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
}
buf.push_str(" ->\n");
buf.push_str(" ->");
newline(buf, indent + INDENT * 2);
add_spaces(buf, indent + (INDENT * 2));
match expr.value {
Expr::SpaceBefore(nested, spaces) => {
fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent + (INDENT * 2));