git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitbb19b0cbfdcee6da1fb146c7a54f6c44e6b50394
parent2b93f2333f
authorLucas Galante <[email protected]>
date2026-08-26 12:54
spreadsheet: ellipsis only when it says more than a clipped glyph

At sub-3-char column budgets the mark replaced the content (a 19px
column fits one glyph, and a bare ellipsis says less than a clipped
digit) — very narrow columns keep the raw string and let the per-column
clamp cut it, exactly the pre-ellipsis rendering.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/widget/container/spreadsheet.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/widget/container/spreadsheet.rs b/src/widget/container/spreadsheet.rs
index 9b8e9e0..658e185 100644
--- a/src/widget/container/spreadsheet.rs
+++ b/src/widget/container/spreadsheet.rs
@@ -282,13 +282,16 @@ impl Paint for Spreadsheet {
         // Ellipsize what the clamp would cut, so truncation reads as
         // deliberate. A char budget from ONE cached measurement is exact
         // because the DE label font is monospace; the clamp bounds stay on
-        // as the backstop for any fallback-font drift.
+        // as the backstop for any fallback-font drift. Below three columns'
+        // worth of budget the mark would REPLACE the content (a 19px column
+        // fits one glyph — a bare "…" says less than a clipped digit), so
+        // very narrow columns keep the raw string and let the clamp cut it.
         let fam = crate::layout::control_label_font();
         let char_w =
             (crate::widget::display::measure_text_width("0123456789", &fam, 12.0) / 10.0).max(1.0);
-        let budget = (((col_w - 12.0) / char_w).floor() as usize).max(1);
+        let budget = ((col_w - 12.0) / char_w).floor() as usize;
         let fit = move |s: String| -> String {
-            if s.chars().count() <= budget {
+            if budget < 3 || s.chars().count() <= budget {
                 return s;
             }
             let mut out: String = s.chars().take(budget - 1).collect();