From dc21aa07f7bbe50780e0f18b32f357242bd7c6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hoffmann?= Date: Sat, 25 Jul 2026 14:48:14 +0200 Subject: [PATCH] fix(ruler): no window-local highlights for last line 'rulerformat' Fixes #38777 in case 'rulerformat' is set. See PR 38879. Original message: Problem: When the 'ruler' is in the last line of the screen, it takes local highlight definitions of the current window, tripping an assert (since c1648cf). Solution: Don't use window-local highlight definitions when the ruler is not part of a statusline. --- src/nvim/statusline.c | 2 +- test/functional/ui/statusline_spec.lua | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 853f2e8a8a..51bafb4238 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -348,7 +348,7 @@ static void win_redr_stl_expr(win_T *wp, bool draw_winbar, bool draw_ruler, bool opt_scope = ((*wp->w_p_stl != NUL) ? OPT_LOCAL : 0); } - attr = win_hl_attr(wp, (int)group); + attr = draw_ruler && !in_status_line ? HL_ATTR(group) : win_hl_attr(wp, (int)group); if (!wp->w_floating && in_status_line && !is_stl_global) { col += wp->w_wincol; } diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 0b676be6f9..c70015b78f 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -818,6 +818,15 @@ describe('statusline', function() {2:[No Name] 0,0-1 All}| 0,0-1 All | ]]) + command('set rulerformat=%17(%l,%c%V%=%P%)') + screen:expect([[ + | + {1:~}{15:^ }{1: }| + {1:~ }|*4 + {2:[No Name] 0,0-1 All}| + 0,0-1 All | + ]]) + command('set rulerformat&') api.nvim_win_close(win, true) screen:expect([[ ^ |