From ce763e0c4b7048ef562320d521116cd0581c17c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 10 Feb 2025 17:02:55 +0530 Subject: [PATCH] Cleaner handling of negative y --- kitty/decorations.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/decorations.c b/kitty/decorations.c index 54e79da0d..27530d42e 100644 --- a/kitty/decorations.c +++ b/kitty/decorations.c @@ -128,9 +128,9 @@ add_dashed_underline(uint8_t *buf, FontCellMetrics fcm) { } static unsigned -add_intensity(uint8_t *buf, unsigned x, unsigned y, uint8_t val, unsigned max_y, unsigned position, unsigned cell_width) { +add_intensity(uint8_t *buf, unsigned x, int y, uint8_t val, unsigned max_y, unsigned position, unsigned cell_width) { y += position; - y = min(y, max_y); + y = min(MAX(0, y), max_y); unsigned idx = cell_width * y + x; buf[idx] = min(255, buf[idx] + val); return y;