]> granicus.if.org Git - vim/commitdiff
patch 8.2.4644: redrawing too often when 'relativenumber' is set v8.2.4644
authorLewis Russell <lewis6991@gmail.com>
Tue, 29 Mar 2022 10:38:17 +0000 (11:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Mar 2022 10:38:17 +0000 (11:38 +0100)
Problem:    Redrawing too often when 'relativenumber' is set.
Solution:   Only redraw when the cursor line changed. (Lewis Russell,
            closes #10040)

src/change.c
src/drawscreen.c
src/structs.h
src/version.c

index 54ed684a6de1d910f6f55b7ac8c1b070ea05baa0..afc32b7241ca112a8af3d69bda709deea9616c91 100644 (file)
@@ -641,7 +641,7 @@ changed_common(
                set_topline(wp, wp->w_topline);
 #endif
            // Relative numbering may require updating more.
-           if (wp->w_p_rnu)
+           if (wp->w_p_rnu && xtra != 0)
                redraw_win_later(wp, SOME_VALID);
 #ifdef FEAT_SYN_HL
            // Cursor line highlighting probably need to be updated with
index cb4757748ff62fef600adac35f9f47fa15d11017..9f9cb096020558cffbbfea6532c04bb9169d6c60 100644 (file)
@@ -2507,11 +2507,11 @@ win_update(win_T *wp)
        }
        else
        {
-           if (wp->w_p_rnu)
+           if (wp->w_p_rnu && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum)
            {
 #ifdef FEAT_FOLDING
-               // 'relativenumber' set: The text doesn't need to be drawn, but
-               // the number column nearly always does.
+               // 'relativenumber' set and the cursor moved vertically: The
+               // text doesn't need to be drawn, but the number column does.
                fold_count = foldedCount(wp, lnum, &win_foldinfo);
                if (fold_count != 0)
                    fold_line(wp, fold_count, &win_foldinfo, lnum, row);
@@ -2553,6 +2553,7 @@ win_update(win_T *wp)
     // update w_last_cursorline.
     wp->w_last_cursorline = wp->w_p_cul ? wp->w_cursor.lnum : 0;
 #endif
+    wp->w_last_cursor_lnum_rnu = wp->w_p_rnu ? wp->w_cursor.lnum : 0;
 
 #ifdef FEAT_VTP
     // Rewrite the character at the end of the screen line.
index a153336c9c422a2ff2f526b9cb440d3fc7fd617f..192693bac4819018538e8067cbd21cf2303952a1 100644 (file)
@@ -3465,6 +3465,9 @@ 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
+
     lcs_chars_T        w_lcs_chars;        // 'listchars' characters
 
     /*
index fe7f299cbd8eaf5325addaddeaabbe6ce1a11679..90b30ab3212369222fad0811d704b1333bf34a03 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4644,
 /**/
     4643,
 /**/