diff options
-rw-r--r-- | src/nvim/drawscreen.c | 47 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 50 |
2 files changed, 73 insertions, 24 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 99f8c70799..a1582eac53 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -978,12 +978,33 @@ win_update_start: return; } + buf_T *buf = wp->w_buffer; + + // reset got_int, otherwise regexp won't work + int save_got_int = got_int; + got_int = 0; + // Set the time limit to 'redrawtime'. + proftime_T syntax_tm = profile_setlimit(p_rdt); + syn_set_timeout(&syntax_tm); + + win_extmark_arr.size = 0; + + decor_redraw_reset(buf, &decor_state); + + DecorProviders line_providers; + decor_providers_invoke_win(wp, providers, &line_providers, &provider_err); + if (must_redraw != 0) { + must_redraw = 0; + if (!called_decor_providers) { + called_decor_providers = true; + goto win_update_start; + } + } + redraw_win_signcol(wp); init_search_hl(wp, &screen_search_hl); - buf_T *buf = wp->w_buffer; - // Force redraw when width of 'number' or 'relativenumber' column // changes. int nrwidth = (wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) : 0; @@ -1496,28 +1517,6 @@ win_update_start: wp->w_old_visual_col = 0; } - // reset got_int, otherwise regexp won't work - int save_got_int = got_int; - got_int = 0; - // Set the time limit to 'redrawtime'. - proftime_T syntax_tm = profile_setlimit(p_rdt); - syn_set_timeout(&syntax_tm); - - win_extmark_arr.size = 0; - - decor_redraw_reset(buf, &decor_state); - - DecorProviders line_providers; - decor_providers_invoke_win(wp, providers, &line_providers, &provider_err); - (void)win_signcol_count(wp); // check if provider changed signcol width - if (must_redraw != 0) { - must_redraw = 0; - if (!called_decor_providers) { - called_decor_providers = true; - goto win_update_start; - } - } - bool cursorline_standout = win_cursorline_standout(wp); win_check_ns_hl(wp); diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9448674a41..e9072ebf98 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -564,6 +564,7 @@ describe('extmark decorations', function() [24] = {bold = true}; [25] = {background = Screen.colors.LightRed}; [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; + [27] = {background = Screen.colors.Plum1}; } ns = meths.create_namespace 'test' @@ -959,6 +960,55 @@ end]] | ]]) end) + + it('avoids redraw issue #20651', function() + exec_lua[[ + vim.cmd.normal'10oXXX' + vim.cmd.normal'gg' + local ns = vim.api.nvim_create_namespace('ns') + + local bufnr = vim.api.nvim_create_buf(false, true) + vim.api.nvim_open_win(bufnr, false, { relative = 'win', height = 1, width = 1, row = 0, col = 0 }) + + vim.api.nvim_create_autocmd('CursorMoved', { callback = function() + local row = vim.api.nvim_win_get_cursor(0)[1] - 1 + vim.api.nvim_buf_set_extmark(0, ns, row, 0, { id = 1 }) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, {}) + vim.schedule(function() + vim.api.nvim_buf_set_extmark(0, ns, row, 0, { + id = 1, + virt_text = {{'HELLO', 'Normal'}}, + }) + end) + end + }) + ]] + + for _ = 1, 3 do + helpers.sleep(10) + feed 'j' + end + + screen:expect{grid=[[ + {27: } | + XXX | + XXX | + ^XXX HELLO | + XXX | + XXX | + XXX | + XXX | + XXX | + XXX | + XXX | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + end) + end) describe('decorations: virtual lines', function() |