]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0892: may redraw when not needed v9.0.0892
authorBram Moolenaar <Bram@vim.org>
Thu, 17 Nov 2022 11:34:38 +0000 (11:34 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 17 Nov 2022 11:34:38 +0000 (11:34 +0000)
Problem:    May redraw when not needed, causing slow scrolling.
Solution:   Do not redraw when w_skipcol doesn't change.  When w_skipcol
            changes only redraw from the top. (issue #11559)

src/ex_getln.c
src/move.c
src/testdir/Make_all.mak
src/testdir/test_alot.vim
src/version.c

index d3119baf25d506025a0655b9bc67f002d11618ec..72f2a3aabf1a30fa6fdcc4d5464ee627ad1591ed 100644 (file)
@@ -393,6 +393,7 @@ finish_incsearch_highlighting(
        magic_overruled = is_state->magic_overruled_save;
 
        validate_cursor();      // needed for TAB
+       status_redraw_all();
        redraw_all_later(UPD_SOME_VALID);
        if (call_update_screen)
            update_screen(UPD_SOME_VALID);
@@ -559,6 +560,7 @@ may_do_incsearch_highlighting(
     }
 
     validate_cursor();
+
     // May redraw the status line to show the cursor position.
     if (p_ru && curwin->w_status_height > 0)
        curwin->w_redr_status = TRUE;
index e255bd68e36ef119d15498e1bdbbf7a819aaecda..3a5f806b5dcc5adc7c7aa6bb6d21dde702e4700f 100644 (file)
@@ -201,6 +201,23 @@ redraw_for_cursorcolumn(win_T *wp)
 }
 #endif
 
+/*
+ * Set curwin->s_skipcol to zero and redraw later if needed.
+ */
+    static void
+reset_skipcol(void)
+{
+    if (curwin->w_skipcol != 0)
+    {
+       curwin->w_skipcol = 0;
+
+       // Should use the least expensive way that displays all that changed.
+       // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw
+       // enough when the top line gets another screen line.
+       redraw_later(UPD_SOME_VALID);
+    }
+}
+
 /*
  * Update curwin->w_topline and redraw if necessary.
  * Used to update the screen before printing a message.
@@ -458,13 +475,9 @@ update_topline(void)
            )
     {
        dollar_vcol = -1;
-       if (curwin->w_skipcol != 0)
-       {
-           curwin->w_skipcol = 0;
-           redraw_later(UPD_NOT_VALID);
-       }
-       else
-           redraw_later(UPD_VALID);
+       redraw_later(UPD_VALID);
+       reset_skipcol();
+
        // May need to set w_skipcol when cursor in w_topline.
        if (curwin->w_cursor.lnum == curwin->w_topline)
            validate_cursor();
@@ -1319,7 +1332,7 @@ curs_columns(
     else if (!curwin->w_p_sms)
        curwin->w_skipcol = 0;
     if (prev_skipcol != curwin->w_skipcol)
-       redraw_later(UPD_NOT_VALID);
+       redraw_later(UPD_SOME_VALID);
 
 #ifdef FEAT_SYN_HL
     redraw_for_cursorcolumn(curwin);
@@ -1849,11 +1862,7 @@ adjust_skipcol(void)
     if (curwin->w_cline_height == curwin->w_height)
     {
        // the line just fits in the window, don't scroll
-       if (curwin->w_skipcol != 0)
-       {
-           curwin->w_skipcol = 0;
-           redraw_later(UPD_NOT_VALID);
-       }
+       reset_skipcol();
        return;
     }
 
@@ -2302,10 +2311,7 @@ scroll_cursor_top(int min_scroll, int always)
 #endif
        // TODO: if the line doesn't fit may optimize w_skipcol
        if (curwin->w_topline == curwin->w_cursor.lnum)
-       {
-           curwin->w_skipcol = 0;
-           redraw_later(UPD_NOT_VALID);
-       }
+           reset_skipcol();
        if (curwin->w_topline != old_topline
                || curwin->w_skipcol != old_skipcol
 #ifdef FEAT_DIFF
@@ -2737,7 +2743,7 @@ cursor_correct(void)
        if (curwin->w_cline_height == curwin->w_height)
        {
            // The cursor line just fits in the window, don't scroll.
-           curwin->w_skipcol = 0;
+           reset_skipcol();
            return;
        }
        // TODO: If the cursor line doesn't fit in the window then only adjust
index 04ccb4804ec7b60919d9b70b48b7b519e3fbfd02..1ac29b1b6a6b337fc1db0226a6efe0c89ec750c5 100644 (file)
@@ -484,6 +484,7 @@ NEW_TESTS_RES = \
        test_retab.res \
        test_ruby.res \
        test_scriptnames.res \
+       test_scroll_opt.res \
        test_scrollbind.res \
        test_search.res \
        test_search_stat.res \
index b7b7eadb31a7b3569b49373f113b59a3529bfe6d..592ca65672d0e9257cb1292e5559058b7265f689 100644 (file)
@@ -19,7 +19,6 @@ source test_global.vim
 source test_move.vim
 source test_put.vim
 source test_reltime.vim
-source test_scroll_opt.vim
 source test_searchpos.vim
 source test_set.vim
 source test_shift.vim
index 0423d0d6432ca14d2f5c14df8e82fa5f5c194956..b526652de3efc4b61a6f576a3b81a09e70409406 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    892,
 /**/
     891,
 /**/