From c84ba83cf1a50d1f892d745c62d9dabb513f3e91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 21 Sep 2025 12:12:37 +0800 Subject: [PATCH] fix(options): increase t_Co buffer size (#35859) (cherry picked from commit c2136e3590082c20fbc210a5578530b2625bf47e) --- src/nvim/option.c | 6 ++---- test/functional/ui/options_spec.lua | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nvim/option.c b/src/nvim/option.c index d5a4d5b08f..d1993756a8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2989,8 +2989,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. @@ -3004,8 +3002,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 index 211fc1dc77..ce52883b0b 100644 --- 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)