From 18d6b2309fc2f8824854882933f11ee95d086f49 Mon Sep 17 00:00:00 2001 From: Artem Krinitsyn Date: Mon, 20 Jul 2026 19:25:24 +0000 Subject: [PATCH 1/3] fix(ui): handle combining chunked float titles Problem: The title is combined with window's attributes only if the title is a string (which implies the FloatTitle / FloatFooter highlight groups), but not when the title is text-hl chunks. Solution: Combine specified highlight group with window-local Normal highlight as well. --- src/nvim/grid.c | 3 ++- test/functional/ui/float_spec.lua | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 97899181c1..7916ec55d7 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -1088,9 +1088,9 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ int win_hl_attr_normal, BorderTextType bt, int overflow) { int default_attr = hl_attr[bt == kBorderTextTitle ? HLF_BTITLE : HLF_BFOOTER]; - default_attr = hl_combine_attr(win_hl_attr_normal, default_attr); if (overflow > 0) { + default_attr = hl_combine_attr(win_hl_attr_normal, default_attr); grid_line_puts(1, "<", -1, hl_apply_winblend(winbl, default_attr)); col += 1; overflow += 1; @@ -1122,6 +1122,7 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ text = p; } attr = hl_apply_winblend(winbl, attr); + attr = hl_combine_attr(win_hl_attr_normal, attr); col += grid_line_puts(col, text, -1, attr); } } diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 2b1fb1d733..49e204b6d7 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -3041,10 +3041,10 @@ describe('float window', function() ## grid 3 | ## grid 4 - {33:╔}🦄{7:BB}{33:═════╗}| + {33:╔}{1:🦄}{7:BB}{33:═════╗}| {33:║}{1: halloj! }{33:║}| {33:║}{1: BORDAA }{33:║}| - {33:╚}🦄{7:BB}{33:═════╝}| + {33:╚}{1:🦄}{7:BB}{33:═════╝}| ]], float_pos = { [4] = { 1001, 'NW', 1, 2, 5, true, 50, 1, 2, 5 } }, win_viewport = { @@ -3057,10 +3057,10 @@ describe('float window', function() grid = [[ ^ | {0:~ }| - {0:~ }{33:╔}🦄{7:BB}{33:═════╗}{0: }| + {0:~ }{33:╔}{1:🦄}{7:BB}{33:═════╗}{0: }| {0:~ }{33:║}{1: halloj! }{33:║}{0: }| {0:~ }{33:║}{1: BORDAA }{33:║}{0: }| - {0:~ }{33:╚}🦄{7:BB}{33:═════╝}{0: }| + {0:~ }{33:╚}{1:🦄}{7:BB}{33:═════╝}{0: }| | ]], } From c6717f1f38c86e61099cfab4be9527f326a0d3b0 Mon Sep 17 00:00:00 2001 From: Artem Krinitsyn Date: Mon, 20 Jul 2026 23:32:50 +0000 Subject: [PATCH 2/3] perf(ui): blend and combine title default attr once --- src/nvim/grid.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 7916ec55d7..01d554b6f6 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -1088,10 +1088,11 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ int win_hl_attr_normal, BorderTextType bt, int overflow) { int default_attr = hl_attr[bt == kBorderTextTitle ? HLF_BTITLE : HLF_BFOOTER]; + default_attr = hl_apply_winblend(winbl, default_attr); + default_attr = hl_combine_attr(win_hl_attr_normal, default_attr); if (overflow > 0) { - default_attr = hl_combine_attr(win_hl_attr_normal, default_attr); - grid_line_puts(1, "<", -1, hl_apply_winblend(winbl, default_attr)); + grid_line_puts(1, "<", -1, default_attr); col += 1; overflow += 1; } @@ -1104,6 +1105,9 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ } if (attr == -1) { // No highlight specified. attr = default_attr; + } else { + attr = hl_apply_winblend(winbl, attr); + attr = hl_combine_attr(win_hl_attr_normal, attr); } // Skip characters from the beginning when title overflows available width. if (overflow > 0) { @@ -1121,8 +1125,6 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ } text = p; } - attr = hl_apply_winblend(winbl, attr); - attr = hl_combine_attr(win_hl_attr_normal, attr); col += grid_line_puts(col, text, -1, attr); } } From 1f045b62ba4d6f74e2afe35a098235ed3a0badaf Mon Sep 17 00:00:00 2001 From: Artem Krinitsyn Date: Mon, 20 Jul 2026 23:40:59 +0000 Subject: [PATCH 3/3] perf(ui): defer title attr resolution In case of an overflow, the iteration will break before the grid_line_puts call. --- src/nvim/grid.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 01d554b6f6..96dc6203c3 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -1103,12 +1103,6 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ if (text == NULL) { break; } - if (attr == -1) { // No highlight specified. - attr = default_attr; - } else { - attr = hl_apply_winblend(winbl, attr); - attr = hl_combine_attr(win_hl_attr_normal, attr); - } // Skip characters from the beginning when title overflows available width. if (overflow > 0) { int cells = (int)mb_string2cells(text); @@ -1125,6 +1119,12 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ } text = p; } + if (attr == -1) { // No highlight specified. + attr = default_attr; + } else { + attr = hl_apply_winblend(winbl, attr); + attr = hl_combine_attr(win_hl_attr_normal, attr); + } col += grid_line_puts(col, text, -1, attr); } }