From c07d540857995a3250a3ede41a0099c758b5cb0f Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Mon, 21 Oct 2024 12:18:30 -0300 Subject: [PATCH] Better way to avoid indenting twice --- tooling/nargo_fmt/src/formatter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/nargo_fmt/src/formatter.rs b/tooling/nargo_fmt/src/formatter.rs index 4f16b0726fd..b7527118995 100644 --- a/tooling/nargo_fmt/src/formatter.rs +++ b/tooling/nargo_fmt/src/formatter.rs @@ -229,9 +229,9 @@ impl<'a> Formatter<'a> { } /// Writes the current indentation to the buffer, but only if the buffer - /// does not end with a space (otherwise we'd be indenting too much). + /// is empty or it ends with a newline (otherwise we'd be indenting when not needed). fn write_indentation(&mut self) { - if self.buffer.ends_with(' ') { + if !(self.buffer.is_empty() || self.buffer.ends_with('\n')) { return; }