diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-03-29 12:37:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 19:37:42 +0800 |
commit | 81d7628c3fadaa72b879b5e934d30c609d7c89f8 (patch) | |
tree | de41b4fff79b958f66c94b8b59c39758585892c6 | |
parent | d89a80fafc6cdf12f72dac2bcbd5055038a241dc (diff) | |
download | rneovim-81d7628c3fadaa72b879b5e934d30c609d7c89f8.tar.gz rneovim-81d7628c3fadaa72b879b5e934d30c609d7c89f8.tar.bz2 rneovim-81d7628c3fadaa72b879b5e934d30c609d7c89f8.zip |
vim-patch:8.2.4644: redrawing too often when 'relativenumber' is set (#17756)
Problem: Redrawing too often when 'relativenumber' is set.
Solution: Only redraw when the cursor line changed. (Lewis Russell,
closes vim/vim#10040)
https://github.com/vim/vim/commit/1624639ec8a6c3c99e417a2990f2f02f0d0b6e10
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/change.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 8 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 29413281ad..08ca1a6247 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1211,6 +1211,8 @@ struct window_S { colnr_T w_old_visual_col; ///< last known start of visual part colnr_T w_old_curswant; ///< last known value of Curswant + linenr_T w_last_cursor_lnum_rnu; ///< cursor lnum when 'rnu' was last redrawn + // 'listchars' characters. Defaults set in set_chars_option(). struct { int eol; diff --git a/src/nvim/change.c b/src/nvim/change.c index 6c3dbf72e4..0644b1d601 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -287,7 +287,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra } // Relative numbering may require updating more. - if (wp->w_p_rnu) { + if (wp->w_p_rnu && xtra != 0) { redraw_later(wp, SOME_VALID); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 67eee55c51..48f00e1a6a 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1577,9 +1577,9 @@ static void win_update(win_T *wp, DecorProviders *providers) idx++; lnum += foldinfo.fi_lines + 1; } else { - if (wp->w_p_rnu) { - // 'relativenumber' set: The text doesn't need to be drawn, but - // the number column nearly always does. + if (wp->w_p_rnu && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum) { + // 'relativenumber' set and cursor moved vertically: The + // text doesn't need to be drawn, but the number column does. foldinfo_T info = fold_info(wp, lnum); (void)win_line(wp, lnum, srow, wp->w_grid.Rows, true, true, info, &line_providers); @@ -1607,6 +1607,8 @@ static void win_update(win_T *wp, DecorProviders *providers) // update w_last_cursorline. wp->w_last_cursorline = cursorline_standout ? wp->w_cursor.lnum : 0; + wp->w_last_cursor_lnum_rnu = wp->w_p_rnu ? wp->w_cursor.lnum : 0; + if (idx > wp->w_lines_valid) { wp->w_lines_valid = idx; } |