From 73e1d328c3d81491d4ac214b269b8c6c1138b5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 25 Aug 2021 13:57:19 +0200 Subject: [PATCH] =?UTF-8?q?particle/list:=20don=E2=80=99t=20adjust=20spaci?= =?UTF-8?q?ng=20if=20all=20sub-items=20are=20zero-width?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That is, if all sub-items are zero-width, make sure *we* return a zero width, instead of a negative width. --- particles/list.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/particles/list.c b/particles/list.c index 9f03231..19ff15b 100644 --- a/particles/list.c +++ b/particles/list.c @@ -39,18 +39,29 @@ static int begin_expose(struct exposable *exposable) { const struct eprivate *e = exposable->private; + bool have_at_least_one = false; - exposable->width = exposable->particle->left_margin; + exposable->width = 0; for (size_t i = 0; i < e->count; i++) { struct exposable *ee = e->exposables[i]; e->widths[i] = ee->begin_expose(ee); - exposable->width += e->left_spacing + e->widths[i] + e->right_spacing; + assert(e->widths[i] >= 0); + + if (e->widths[i] > 0) { + exposable->width += e->left_spacing + e->widths[i] + e->right_spacing; + have_at_least_one = true; + } } - exposable->width -= e->left_spacing + e->right_spacing; - exposable->width += exposable->particle->right_margin; + if (have_at_least_one) { + exposable->width -= e->left_spacing + e->right_spacing; + exposable->width += exposable->particle->left_margin; + exposable->width += exposable->particle->right_margin; + } else + assert(exposable->width == 0); + return exposable->width; }