From 2d37bcc295b20edd893ee82bf67c075c94181088 Mon Sep 17 00:00:00 2001 From: Gerrit Viljoen Date: Sun, 17 May 2020 12:40:30 +0200 Subject: [PATCH] save game --- src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 018c654..f781995 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -354,7 +354,9 @@ impl SmartString { while let Some(ch) = iter.next() { if visible { if ch == '\u{1b}' && Some(&'[') == iter.peek() { - fragments.push((visible, buf)); + if !buf.is_empty() { + fragments.push((visible, buf)); + } visible = !visible; buf = String::new(); } @@ -362,11 +364,15 @@ impl SmartString { } else { if ch == 'm' { buf.push(ch); - fragments.push((visible, buf)); + if !buf.is_empty() { + fragments.push((visible, buf)); + } visible = !visible; buf = String::new(); } else if ch != '[' && ch != ';' && !('0'..='9').contains(&ch) { - fragments.push((visible, buf)); + if !buf.is_empty() { + fragments.push((visible, buf)); + } visible = !visible; buf = String::new(); buf.push(ch);