chiark / gitweb /
Forgot trailing '.' on FileStatusLine without proportion.
authorSimon Tatham <anakin@pobox.com>
Thu, 28 Dec 2023 12:01:44 +0000 (12:01 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 28 Dec 2023 12:03:03 +0000 (12:03 +0000)
src/text.rs

index 26cd15304d5e69715ebff643dd020afc65733b9f..db1d3cf9547d6422d50401a6a455b640db9cabe1 100644 (file)
@@ -1262,7 +1262,11 @@ impl TextFragment for FileStatusLineFinal {
         let cpropwidth = if let Some(cprop) = &cprop { cprop.width() } else {0};
         let extraspace = if !line.is_empty() && cpropwidth > 0 {
             FileStatusLine::SPACING
-        } else {0};
+        } else if !cprop.is_some() {
+            1 // trailing '.' if no proportion
+        } else {
+            0
+        };
 
         let avail = width - min(
             width, line.width() + cpropwidth + extraspace + 1);
@@ -1287,6 +1291,8 @@ impl TextFragment for FileStatusLineFinal {
 
         if let Some(cprop) = cprop {
             push(&mut line, cprop.slice());
+        } else {
+            line.push_str(&ColouredString::plain(".").slice());
         }
 
         // Done. Now centre it in the available space.
@@ -1371,16 +1377,16 @@ fn test_filestatus_render() {
         .add(OurKey::Pr('K'), "Keypress", 10)
         .finalise();
 
-    assert_eq!(fs.render(21), vec! {
+    assert_eq!(fs.render(22), vec! {
             ColouredString::general(
-                "weasel  [K]:Keypress",
-                "         k          "),
+                "weasel  [K]:Keypress.",
+                "         k           "),
         });
 
-    assert_eq!(fs.render(20), vec! {
+    assert_eq!(fs.render(21), vec! {
             ColouredString::general(
-                "      weasel",
-                "            "),
+                "      weasel.",
+                "             "),
         });
 }