From a89c385f338d7464d07889670bb8c6edbbad124c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Sep 2023 06:05:38 +0800 Subject: [PATCH] fix(statuscolumn): update number hl for each screen line (cherry picked from commit b2332e08538f5f662110dd6afc8454eb7dc0924c) --- src/nvim/drawline.c | 6 ++++-- test/functional/ui/statuscolumn_spec.lua | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index d5d33c634d..2b78f245e0 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1308,8 +1308,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, statuscol.width = win_col_off(wp) - (cmdwin_type != 0 && wp == curwin); statuscol.use_cul = use_cursor_line_highlight(wp, lnum); statuscol.sign_cul_id = statuscol.use_cul ? sign_cul.hl_id : 0; - statuscol.num_attr = sign_num.hl_id ? syn_id2attr(sign_num.hl_id) - : get_line_number_attr(wp, &wlv); + statuscol.num_attr = sign_num.hl_id > 0 ? syn_id2attr(sign_num.hl_id) : 0; } else { if (sign_cul.hl_id > 0) { sign_cul_attr = syn_id2attr(sign_cul.hl_id); @@ -1602,6 +1601,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, wlv.draw_state = WL_STC; // Draw the 'statuscolumn' if option is set. if (statuscol.draw) { + if (sign_num.hl_id == 0) { + statuscol.num_attr = get_line_number_attr(wp, &wlv); + } if (statuscol.textp == NULL) { v = (ptr - line); get_statuscol_str(wp, lnum, wlv.row - startrow - wlv.filler_lines, &statuscol); diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index d3684f74d8..c696784b2c 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -473,7 +473,7 @@ describe('statuscolumn', function() aaaaaaaaa | {1:virtual-2 15}virt_line1 | {1:virtual-2 15}virt_line2 | - {1:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {5:aaaaaaaaa }| {1:virtual-1 16}END | {0:~ }|