Merge pull request #202 from lj3954/preview_word_wrap

feat: Add word wrap to preview window
This commit is contained in:
Chris Titus 2024-09-02 16:44:07 -05:00 committed by GitHub
commit 17f9f721af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,8 +68,18 @@ impl FloatContent for FloatingText {
.text
.iter()
.skip(self.scroll)
.flat_map(|line| {
if line.is_empty() {
return vec![String::new()];
}
line.chars()
.collect::<Vec<char>>()
.chunks(inner_area.width as usize)
.map(|chunk| chunk.iter().collect())
.collect::<Vec<String>>()
})
.take(inner_area.height as usize)
.map(|line| Line::from(line.as_str()))
.map(Line::from)
.collect();
// Create list widget