chiark / gitweb /
Fix paragraph wrap width.
authorSimon Tatham <anakin@pobox.com>
Fri, 29 Dec 2023 14:32:23 +0000 (14:32 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 29 Dec 2023 18:17:34 +0000 (18:17 +0000)
We were wrapping to the full screen width, instead of Monochrome's
traditional w-1.

src/text.rs

index e55c4340d6d5ee3d570c44fbd4bc3acf3370282f..1d46e5de195b48538e1b991153e024e6ab9d104d 100644 (file)
@@ -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<ColouredString> {
-        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();