From 41b2e8b1e1d1415a43baa6393b7237e7e77468eb Mon Sep 17 00:00:00 2001 From: adnano Date: Mon, 25 Mar 2024 08:20:36 -0400 Subject: menu: Avoid adding zero-size pages Ensure that pages always have at least one item, even if that item is too big to fit on any page. --- menu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'menu.c') diff --git a/menu.c b/menu.c index f95409f..e4a8e1c 100644 --- a/menu.c +++ b/menu.c @@ -219,11 +219,13 @@ static void page_items(struct menu *menu) { page->first = item; int total_width = 0; + int items = 0; while (item) { total_width += item->width + 2 * menu->padding; - if (total_width > max_width) { + if (total_width > max_width && items > 0) { break; } + items++; item->page = page; page->last = item; -- cgit v1.2.3