From 862b58b8f9e20a27976e060a08be96bd7fe1ad7f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 4 Aug 2022 23:11:10 -0400 Subject: [PATCH] Fix `expect` formatting in expressions --- crates/compiler/fmt/src/expr.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 53867e929f..0ac5825f18 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -815,16 +815,24 @@ fn fmt_expect<'a, 'buf>( is_multiline: bool, indent: u16, ) { + buf.ensure_ends_with_newline(); + buf.indent(indent); + buf.push_str("expect"); + let return_indent = if is_multiline { + buf.newline(); indent + INDENT } else { + buf.spaces(1); indent }; - buf.push_str("expect"); condition.format(buf, return_indent); - buf.push('\n'); - continuation.format(buf, return_indent); + + // Always put a blank line after the `expect` line(s) + buf.ensure_ends_with_blank_line(); + + continuation.format(buf, indent); } fn fmt_if<'a, 'buf>(