From c562c78fcdf5af760ec065d564dc56c2abcbb8c6 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Tue, 21 Jan 2020 15:14:27 -0800 Subject: [PATCH] fix bug in cell styling --- src/editor/mod.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 43675c8..6d16ba9 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -128,18 +128,12 @@ impl Editor { } for (col_index, cell) in row.iter().enumerate() { - if let Some((character, new_style)) = cell { - if !command_matches(&command, &new_style) { - add_command(&mut draw_commands, command); - command = None; - } - add_character(&mut command, &character, row_index as u64, col_index as u64, new_style.clone()); - } else { - let style = command.as_ref().map(|command| command.style.clone()).flatten(); - add_character(&mut command, &' ', row_index as u64, col_index as u64, style); - // add_command(&mut draw_commands, command); - // command = None; + let (character, style) = cell.clone().unwrap_or_else(|| (' ', Some(Style::new(self.default_colors.clone())))); + if !command_matches(&command, &style) { + add_command(&mut draw_commands, command); + command = None; } + add_character(&mut command, &character, row_index as u64, col_index as u64, style.clone()); } add_command(&mut draw_commands, command); }