From 94085cfce82153e79eba5a1d277fe5799d973ffd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 13 Feb 2024 06:56:19 +0800 Subject: perf(redraw): reduce redraw with undo and extmarks or 'spell' (#27442) vim-patch:9.1.0100: Redrawing can be improved with undo and 'spell' Problem: When undoing with 'spell', redrawWinline() is called after changed_lines(), while later win_update() sets redraw type to UPD_NOT_VALID, even though w_redraw_top and w_redraw_bot are still valid. Solution: Only set redraw type to UPD_NOT_VALID when inserting/deleting lines after parts of window has pending redraw, i.e., when changed_lines() is called after redrawWinline(). (zeertzjq) closes: vim/vim#14019 https://github.com/vim/vim/commit/f2d90a351159fd6843f450850f52004f42e00183 --- src/nvim/change.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/change.c') diff --git a/src/nvim/change.c b/src/nvim/change.c index a7c885bf4d..1c7724f010 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -326,6 +326,13 @@ static void changed_common(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnum wp->w_redr_type = UPD_VALID; } + // When inserting/deleting lines and the window has specific lines + // to be redrawn, w_redraw_top and w_redraw_bot may now be invalid, + // so just redraw everything. + if (xtra != 0 && wp->w_redraw_top != 0) { + redraw_later(wp, UPD_NOT_VALID); + } + linenr_T last = lnume + xtra - 1; // last line after the change // Reset "w_skipcol" if the topline length has become smaller to -- cgit