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)
1624639ec8
This commit is contained in:
Lewis Russell
2022-03-29 12:37:42 +01:00
committed by GitHub
parent d89a80fafc
commit 81d7628c3f
3 changed files with 8 additions and 4 deletions

View File

@@ -1211,6 +1211,8 @@ struct window_S {
colnr_T w_old_visual_col; ///< last known start of visual part colnr_T w_old_visual_col; ///< last known start of visual part
colnr_T w_old_curswant; ///< last known value of Curswant 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(). // 'listchars' characters. Defaults set in set_chars_option().
struct { struct {
int eol; int eol;

View File

@@ -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. // Relative numbering may require updating more.
if (wp->w_p_rnu) { if (wp->w_p_rnu && xtra != 0) {
redraw_later(wp, SOME_VALID); redraw_later(wp, SOME_VALID);
} }

View File

@@ -1577,9 +1577,9 @@ static void win_update(win_T *wp, DecorProviders *providers)
idx++; idx++;
lnum += foldinfo.fi_lines + 1; lnum += foldinfo.fi_lines + 1;
} else { } else {
if (wp->w_p_rnu) { if (wp->w_p_rnu && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum) {
// 'relativenumber' set: The text doesn't need to be drawn, but // 'relativenumber' set and cursor moved vertically: The
// the number column nearly always does. // text doesn't need to be drawn, but the number column does.
foldinfo_T info = fold_info(wp, lnum); foldinfo_T info = fold_info(wp, lnum);
(void)win_line(wp, lnum, srow, wp->w_grid.Rows, true, true, (void)win_line(wp, lnum, srow, wp->w_grid.Rows, true, true,
info, &line_providers); info, &line_providers);
@@ -1607,6 +1607,8 @@ static void win_update(win_T *wp, DecorProviders *providers)
// update w_last_cursorline. // update w_last_cursorline.
wp->w_last_cursorline = cursorline_standout ? wp->w_cursor.lnum : 0; 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) { if (idx > wp->w_lines_valid) {
wp->w_lines_valid = idx; wp->w_lines_valid = idx;
} }