From e9db67b2fabed6c613a3e55513013c693a6b3c49 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:48:29 -0700 Subject: [PATCH 1/2] feat: Add word wrap to preview window --- src/floating_text.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/floating_text.rs b/src/floating_text.rs index 1dc8520e..7e041ae9 100644 --- a/src/floating_text.rs +++ b/src/floating_text.rs @@ -68,8 +68,15 @@ impl FloatContent for FloatingText { .text .iter() .skip(self.scroll) + .flat_map(|line| { + line.chars() + .collect::>() + .chunks(inner_area.width as usize) + .map(|chunk| chunk.iter().collect()) + .collect::>() + }) .take(inner_area.height as usize) - .map(|line| Line::from(line.as_str())) + .map(Line::from) .collect(); // Create list widget From 226360081abdadcf8ab83e59712e9462ee895bb7 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:13:48 -0700 Subject: [PATCH 2/2] fix: Render empty lines --- src/floating_text.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/floating_text.rs b/src/floating_text.rs index 7e041ae9..482a8822 100644 --- a/src/floating_text.rs +++ b/src/floating_text.rs @@ -69,6 +69,9 @@ impl FloatContent for FloatingText { .iter() .skip(self.scroll) .flat_map(|line| { + if line.is_empty() { + return vec![String::new()]; + } line.chars() .collect::>() .chunks(inner_area.width as usize)