From 39403458bcf9f25fc4fc0ed4ce153a5ef1d5bcdb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 28 Dec 2023 12:01:44 +0000 Subject: [PATCH] Forgot trailing '.' on FileStatusLine without proportion. --- src/text.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/text.rs b/src/text.rs index 26cd153..db1d3cf 100644 --- a/src/text.rs +++ b/src/text.rs @@ -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.", + " "), }); } -- 2.30.2