From 0613faf5967ff0eb5b51fed08538c90f8fe1bf8d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 26 Jun 2025 13:16:19 +0800 Subject: [PATCH] fix(column): missing redraw with virt_lines_leftcol (#34650) Problem: Missing number column redraw with virt_lines_leftcol. Solution: Set virt_line_index to -1 when skipping a virtual line. --- src/nvim/drawline.c | 1 + test/functional/ui/decorations_spec.lua | 65 +++++++++++++++++++------ 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 7205d65c5c..452495f440 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1688,6 +1688,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b break; } wlv.filler_todo--; + virt_line_index = -1; if (wlv.filler_todo == 0 && (wp->w_botfill || !draw_text)) { break; } diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index a69b8df4e4..00995b6a51 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -5458,7 +5458,7 @@ if (h->n_buckets < new_n_buckets) { // expand insert(example_text2) feed 'gg' command 'set number signcolumn=yes' - screen:expect{grid=[[ + screen:expect([[ {7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| {7: }{8: }d | {7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| @@ -5471,16 +5471,16 @@ if (h->n_buckets < new_n_buckets) { // expand {7: }{8: 6 } h->vals_buf = new_vals; | {7: }{8: 7 } } | | - ]]} + ]]) local markid = api.nvim_buf_set_extmark(0, ns, 2, 0, { - virt_lines={ - {{"Some special", "Special"}}; - {{"remark about codes", "Comment"}}; - }; + virt_lines = { + { { 'Some special', 'Special' } }, + { { 'remark about codes', 'Comment' } }, + }, }) - screen:expect{grid=[[ + screen:expect([[ {7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| {7: }{8: }d | {7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| @@ -5493,17 +5493,17 @@ if (h->n_buckets < new_n_buckets) { // expand {7: }{8: 5 } char *new_vals = krealloc( h->vals_buf, | {7: }{8: }new_n_buckets * val_size); | | - ]]} + ]]) api.nvim_buf_set_extmark(0, ns, 2, 0, { - virt_lines={ - {{"Some special", "Special"}}; - {{"remark about codes", "Comment"}}; - }; - virt_lines_leftcol=true; - id=markid; + virt_lines = { + { { 'Some special', 'Special' } }, + { { 'remark about codes', 'Comment' } }, + }, + virt_lines_leftcol = true, + id = markid, }) - screen:expect{grid=[[ + screen:expect([[ {7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| {7: }{8: }d | {7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| @@ -5516,7 +5516,40 @@ if (h->n_buckets < new_n_buckets) { // expand {7: }{8: 5 } char *new_vals = krealloc( h->vals_buf, | {7: }{8: }new_n_buckets * val_size); | | - ]]} + ]]) + + command('set nonumber relativenumber') + screen:expect([[ + {7: }{8: 0 }^if (h->n_buckets < new_n_buckets) { // expan| + {7: }{8: }d | + {7: }{8: 1 } khkey_t *new_keys = (khkey_t *)krealloc((v| + {7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| + {7: }{8: }t)); | + {7: }{8: 2 } h->keys = new_keys; | + {16:Some special} | + {18:remark about codes} | + {7: }{8: 3 } if (kh_is_map && val_size) { | + {7: }{8: 4 } char *new_vals = krealloc( h->vals_buf, | + {7: }{8: }new_n_buckets * val_size); | + | + ]]) + + -- 'relativenumber' is redrawn with virt_lines_leftcol #34649 + feed('j') + screen:expect([[ + {7: }{8: 1 }if (h->n_buckets < new_n_buckets) { // expan| + {7: }{8: }d | + {7: }{8: 0 }^ khkey_t *new_keys = (khkey_t *)krealloc((v| + {7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| + {7: }{8: }t)); | + {7: }{8: 1 } h->keys = new_keys; | + {16:Some special} | + {18:remark about codes} | + {7: }{8: 2 } if (kh_is_map && val_size) { | + {7: }{8: 3 } char *new_vals = krealloc( h->vals_buf, | + {7: }{8: }new_n_buckets * val_size); | + | + ]]) end) it('works with hard TABs', function()