From 7d6c049870f7140f6656db7d36416d597b3195c6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 2 Dec 2024 20:44:44 +0200 Subject: [PATCH] prepend new line before next lines only --- src/line/code/multiline.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/line/code/multiline.rs b/src/line/code/multiline.rs index 9ca4bc6..06ab1de 100644 --- a/src/line/code/multiline.rs +++ b/src/line/code/multiline.rs @@ -38,16 +38,19 @@ impl Multiline { return Err(Error::Completed); } - // Append to value, trim close tag on exists - self.value.push_str(line.trim_end_matches(TAG)); - // Line contain close tag if line.ends_with(TAG) { self.completed = true; - } else { + } + + // Prepend new line before next lines only + if !self.value.is_empty() { self.value.push(NEW_LINE); } + // Append to value, trim close tag on exists + self.value.push_str(line.trim_end_matches(TAG)); + Ok(()) } }