fix: measure full stack leaf width

Measure every rendered line when a column determines its natural width so a narrower first Grid line cannot cause later lines to overflow after stack padding.\n\nVerified with make check; core 545/545 and Grid 11/11 passed.
This commit is contained in:
Kinneyzhang 2026-08-05 12:01:36 +08:00
parent 8a8e862098
commit de6f56637b
2 changed files with 18 additions and 1 deletions

View File

@ -2774,7 +2774,8 @@ stack itself uses its natural max child width."
(let* ((rendered-items
(mapcar (lambda (leaf)
(let ((rendered (ebox--render-with-cache leaf)))
(cons rendered (ebox--string-pixel-width rendered))))
(cons rendered
(ebox--string-max-pixel-width rendered))))
(ebox--stack-leaves node)))
(max-w (apply #'max (mapcar #'cdr rendered-items)))
(target-w (if ebox--intrinsic-layout-measurement

View File

@ -37,6 +37,22 @@
(should (= (length lines) 1))
(should (= (ebox--string-pixel-width (car lines)) 120))))
(ert-deftest ebox-grid-keeps-padded-items-inside-column-width ()
"Stack padding should use the widest Grid line instead of its first line."
(let* ((header (ebox-create :content "Header" :width '(720)))
(grid (ebox-grid
:width '(718)
:grid-template-columns '((220) 1fr)
:gap '(1 (12))
:border "#C97252"
(ebox-create :content "Fixed" :width '(196)
:padding '(1 (12)))
(ebox-create :content "Fractional" :width '(460)
:padding '(1 (12)))))
(lines (ebox-string-lines (ebox-render (ebox-column header grid))))
(widths (mapcar #'ebox--string-pixel-width lines)))
(should (= (apply #'max widths) 720))))
(ert-deftest ebox-grid-supports-explicit-placement-and-span ()
"Explicit placement should support a cell spanning two columns."
(let ((plain