mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
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:
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user