From 492b7f7b9406b8e460c4a64aed45c70a8a8e152d Mon Sep 17 00:00:00 2001
From: para <para@danwin1210.de>
Date: Fri, 1 Mar 2024 17:13:39 +0200
Subject: Fix style character handling bug

In some ncurses implementations[1], waddnstr returns ERR when len is 0.
This happens in styleAdd() whenever there is a sequence of more than 1
style character in a row.

This may result in visual bugs, the most notable of which is being
unable to see the messages that mention you (due to the "\26\3"
sequence).

In order to properly handle multiple style characters in a row, waddnstr
should only be called when len is greater than 0.

Tested on Alpine Linux, using the official ncurses package.
[1]https://invisible-island.net/ncurses
---
 window.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/window.c b/window.c
index 00041aa..f700fd7 100644
--- a/window.c
+++ b/window.c
@@ -147,6 +147,7 @@ static int styleAdd(WINDOW *win, struct Style init, const char *str) {
 	struct Style style = init;
 	while (*str) {
 		size_t len = styleParse(&style, &str);
+		if (!len) continue;
 		wattr_set(win, uiAttr(style), uiPair(style), NULL);
 		if (waddnstr(win, str, len) == ERR)
 			return -1;
-- 
cgit 1.4.1