]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1136: Match highlighting marks a buffer region as changed v9.1.1136
authorLuuk van Baal <luukvbaal@gmail.com>
Sat, 22 Feb 2025 08:19:04 +0000 (09:19 +0100)
committerChristian Brabandt <cb@256bit.org>
Sat, 22 Feb 2025 08:19:04 +0000 (09:19 +0100)
Problem:  Match highlighting marks a buffer region to be redrawn as if
          its buffer text was changed, unnecessarily invoking syntax code.
Solution: Set the `w_redraw_top/bot` variables instead of the b_mod_* ones
          (Luuk van Baal)

closes: #16697

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawscreen.c
src/fold.c
src/match.c
src/proto/drawscreen.pro
src/version.c

index a08cea3d61d2476d4c0fc9abfa81070ae1c6cb17..4736bf11201dc2a2eb742c5068ea42a773f96cfa 100644 (file)
@@ -3365,9 +3365,21 @@ redrawWinline(
     win_T      *wp,
     linenr_T   lnum)
 {
-    if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum)
-       wp->w_redraw_top = lnum;
-    if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum)
-       wp->w_redraw_bot = lnum;
-    redraw_win_later(wp, UPD_VALID);
+    redraw_win_range_later(wp, lnum, lnum);
+}
+
+    void
+redraw_win_range_later(
+    win_T      *wp,
+    linenr_T   first,
+    linenr_T   last)
+{
+    if (last >= wp->w_topline && first < wp->w_botline)
+    {
+       if (wp->w_redraw_top == 0 || wp->w_redraw_top > first)
+           wp->w_redraw_top = first;
+       if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < last)
+           wp->w_redraw_bot = last;
+       redraw_win_later(wp, UPD_VALID);
+    }
 }
index 64f9447b721304983032548024a54aa5fdc6a373..b165dc9b0ee9d28f63e9f4720812434ca7c15b60 100644 (file)
@@ -2384,12 +2384,7 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
     // this in other situations, the changed lines will be redrawn anyway and
     // this method can cause the whole window to be updated.
     if (end != bot)
-    {
-       if (wp->w_redraw_top == 0 || wp->w_redraw_top > top)
-           wp->w_redraw_top = top;
-       if (wp->w_redraw_bot < end)
-           wp->w_redraw_bot = end;
-    }
+       redraw_win_range_later(wp, top, end);
 
     invalid_top = (linenr_T)0;
 }
index bc50757b37a516f01af8dce87b8d8024a83b7ad8..ef2587947dcb5a0ef9d17ad3d24c7c382c680003 100644 (file)
@@ -187,20 +187,7 @@ match_add(
        // Calculate top and bottom lines for redrawing area
        if (toplnum != 0)
        {
-           if (wp->w_buffer->b_mod_set)
-           {
-               if (wp->w_buffer->b_mod_top > toplnum)
-                   wp->w_buffer->b_mod_top = toplnum;
-               if (wp->w_buffer->b_mod_bot < botlnum)
-                   wp->w_buffer->b_mod_bot = botlnum;
-           }
-           else
-           {
-               wp->w_buffer->b_mod_set = TRUE;
-               wp->w_buffer->b_mod_top = toplnum;
-               wp->w_buffer->b_mod_bot = botlnum;
-               wp->w_buffer->b_mod_xlines = 0;
-           }
+           redraw_win_range_later(wp, toplnum, botlnum);
            m->mit_toplnum = toplnum;
            m->mit_botlnum = botlnum;
            rtype = UPD_VALID;
@@ -269,20 +256,7 @@ match_delete(win_T *wp, int id, int perr)
     vim_free(cur->mit_pattern);
     if (cur->mit_toplnum != 0)
     {
-       if (wp->w_buffer->b_mod_set)
-       {
-           if (wp->w_buffer->b_mod_top > cur->mit_toplnum)
-               wp->w_buffer->b_mod_top = cur->mit_toplnum;
-           if (wp->w_buffer->b_mod_bot < cur->mit_botlnum)
-               wp->w_buffer->b_mod_bot = cur->mit_botlnum;
-       }
-       else
-       {
-           wp->w_buffer->b_mod_set = TRUE;
-           wp->w_buffer->b_mod_top = cur->mit_toplnum;
-           wp->w_buffer->b_mod_bot = cur->mit_botlnum;
-           wp->w_buffer->b_mod_xlines = 0;
-       }
+       redraw_win_range_later(wp, cur->mit_toplnum, cur->mit_botlnum);
        rtype = UPD_VALID;
     }
     vim_free(cur->mit_pos_array);
index 6fa5e2c4511dd13ef30f5cf1bf0bef998f586dc6..6f1d3e37a90a5b7dfa91066e6f13bc1f69c6d164 100644 (file)
@@ -24,4 +24,5 @@ void status_redraw_curbuf(void);
 void redraw_statuslines(void);
 void win_redraw_last_status(frame_T *frp);
 void redrawWinline(win_T *wp, linenr_T lnum);
+void redraw_win_range_later(win_T *wp, linenr_T first, linenr_T last);
 /* vim: set ft=c : */
index 4a9af920b2f09c61d62d522f55aff76b7b079b49..792747e55da4a4ac12c8f9289edd4fc0baf662f4 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1136,
 /**/
     1135,
 /**/