From de6f56637b6825bf1a0d4edbdebd2193de3837b9 Mon Sep 17 00:00:00 2001 From: Kinneyzhang Date: Wed, 5 Aug 2026 12:01:36 +0800 Subject: [PATCH] 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. --- ebox-layout.el | 3 ++- tests/ebox-grid-tests.el | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ebox-layout.el b/ebox-layout.el index 0bc44e5..0d07292 100644 --- a/ebox-layout.el +++ b/ebox-layout.el @@ -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 diff --git a/tests/ebox-grid-tests.el b/tests/ebox-grid-tests.el index 0018f93..cf30bec 100644 --- a/tests/ebox-grid-tests.el +++ b/tests/ebox-grid-tests.el @@ -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