commit c2136e3590082c20fbc210a5578530b2625bf47e
parent f60f67c2de0f3e03309233e6e247313af8fc4018
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun, 21 Sep 2025 12:12:37 +0800
fix(options): increase t_Co buffer size (#35859)
Diffstat:
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/nvim/option.c b/src/nvim/option.c
@@ -2993,8 +2993,6 @@ bool is_tty_option(const char *name)
return find_tty_option_end(name) != NULL;
}
-#define TCO_BUFFER_SIZE 8
-
/// Get value of TTY option.
///
/// @param name Name of TTY option.
@@ -3008,8 +3006,8 @@ OptVal get_tty_option(const char *name)
if (t_colors <= 1) {
value = xstrdup("");
} else {
- value = xmalloc(TCO_BUFFER_SIZE);
- snprintf(value, TCO_BUFFER_SIZE, "%d", t_colors);
+ value = xmalloc(NUMBUFLEN);
+ snprintf(value, NUMBUFLEN, "%d", t_colors);
}
} else if (strequal(name, "term")) {
value = p_term ? xstrdup(p_term) : xstrdup("nvim");
diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua
@@ -228,7 +228,12 @@ describe('UI can set terminal option', function()
it('term_colors', function()
eq('256', eval '&t_Co')
- local _ = Screen.new(20, 5, { term_colors = 8 })
+ local screen = Screen.new(20, 5, { term_colors = 8 })
eq('8', eval '&t_Co')
+ screen:detach()
+
+ screen = Screen.new(20, 5, { term_colors = 16777216 })
+ eq('16777216', eval '&t_Co')
+ screen:detach()
end)
end)