git.lucas.co / cce-mail
mail client (IMAP/SMTP)
git clone https://git.lucas.co/cce-mail.git

commitb4cb2024247b308a21962442f30461a7322c814e
parenta7ebf54b31
authorLucas Galante <lsgalante12@gmail.com>
date2026-09-28 19:36
chore: drop the unused width ellipsizer

No header line ellipsizes any more (a7ebf54), which left
ellipsize_to_width and its test without a caller.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

 src/main.rs | 43 -------------------------------------------
 1 file changed, 43 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index f2b75f3..d3ddeca 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1264,34 +1264,6 @@ fn ellipsize(s: &str, max_chars: usize) -> String {
     }
 }
 
-/// Ellipsize `s` so its estimated rendered width at `font_size` fits in
-/// `max_w` px. [`ellipsize`] budgets by CHARACTER count, which is fine for
-/// list rows that are also clipped to their viewport, but the detail pane's
-/// header lines were emitted with no bounds and no budget at all, so a long
-/// subject ran straight off the plate. The estimate is the same heuristic the
-/// date column and the empty-pane placeholder already lay out by; callers
-/// still clip at the plate edge so an under-estimate is cut, not overflowed.
-fn ellipsize_to_width(s: &str, font_size: f32, max_w: f32) -> String {
-    if TextLabel::estimate_width(s, font_size) <= max_w {
-        return s.to_string();
-    }
-    let chars: Vec<char> = s.chars().collect();
-    // Largest prefix whose width, plus the ellipsis, still fits. Widths are
-    // monotone in prefix length, so a binary search over the count is exact.
-    let (mut lo, mut hi) = (0usize, chars.len());
-    while lo < hi {
-        let mid = (lo + hi).div_ceil(2);
-        let candidate: String = chars[..mid].iter().collect::<String>() + "...";
-        if TextLabel::estimate_width(&candidate, font_size) <= max_w {
-            lo = mid;
-        } else {
-            hi = mid - 1;
-        }
-    }
-    let head: String = chars[..lo].iter().collect();
-    format!("{}...", head.trim_end())
-}
-
 /// Display form of the From address: "Name <addr>", falling back through the
 /// parts. mail-parser has already decoded any RFC 2047 encoded-words.
 fn format_from(msg: &mail_parser::Message) -> String {
@@ -6739,21 +6711,6 @@ fn main() {
 
 #[cfg(test)]
 mod tests {
-    #[test]
-    fn ellipsize_to_width_fits_the_column() {
-        let long = "Re: A very long subject line that certainly will not fit in a narrow detail pane column";
-        let fitted = ellipsize_to_width(long, 15.0, 200.0);
-        assert!(fitted.ends_with("..."));
-        assert!(TextLabel::estimate_width(&fitted, 15.0) <= 200.0, "{fitted}");
-        // One more char would not have fit: the prefix is maximal.
-        let head_len = fitted.trim_end_matches("...").chars().count();
-        let longer: String = long.chars().take(head_len + 2).collect::<String>() + "...";
-        assert!(TextLabel::estimate_width(&longer, 15.0) > 200.0);
-        // Short text is untouched, and a hopeless width degrades to the ellipsis alone.
-        assert_eq!(ellipsize_to_width("Hi", 15.0, 200.0), "Hi");
-        assert_eq!(ellipsize_to_width("Hello world", 15.0, 1.0), "...");
-    }
-
     use super::*;
 
     #[test]