From 28bb4b9aee33fccdfb55d935a730e6f0c5e84e07 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 29 Dec 2023 14:32:23 +0000 Subject: [PATCH] Fix paragraph wrap width. We were wrapping to the full screen width, instead of Monochrome's traditional w-1. --- src/text.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/text.rs b/src/text.rs index e55c434..1d46e5d 100644 --- a/src/text.rs +++ b/src/text.rs @@ -381,7 +381,7 @@ impl TextFragment for Paragraph { if !word.is_space() { if self.wrap && break_pos > start_pos && - curr_width - start_width + curr_indent > width { + curr_width - start_width + curr_indent >= width { let mut line = ColouredString::plain(" ") .repeat(curr_indent); for i in start_pos..break_pos { @@ -416,7 +416,7 @@ impl TextFragment for Paragraph { fn test_para_wrap() { let p = Paragraph::new().add(&ColouredString::plain( "the quick brown fox jumps over the lazy dog")); - assert_eq!(p.render(15), vec! { + assert_eq!(p.render(16), vec! { ColouredString::plain("the quick brown"), ColouredString::plain("fox jumps over"), ColouredString::plain("the lazy dog"), @@ -849,7 +849,7 @@ impl InReplyToLine { impl TextFragment for InReplyToLine { fn render(&self, width: usize) -> Vec { - let rendered_para = self.para.render(width - min(width, 4)); + let rendered_para = self.para.render(width - min(width, 3)); let mut it = rendered_para.iter(); // "Re:" guarantees the first line must exist at least let first_line = it.next().unwrap(); -- 2.30.2