]> granicus.if.org Git - vim/commitdiff
patch 9.0.0245: mechanism to prevent recursive screen updating is incomplete v9.0.0245
authorBram Moolenaar <Bram@vim.org>
Mon, 22 Aug 2022 14:19:16 +0000 (15:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 22 Aug 2022 14:19:16 +0000 (15:19 +0100)
Problem:    Mechanism to prevent recursive screen updating is incomplete.
Solution:   Add "redraw_not_allowed" and set it in build_stl_str_hl().
            (issue #10952)

13 files changed:
src/buffer.c
src/change.c
src/digraph.c
src/drawscreen.c
src/ex_docmd.c
src/globals.h
src/highlight.c
src/main.c
src/message.c
src/misc1.c
src/proto/drawscreen.pro
src/screen.c
src/version.c

index 203238ff7821500e3d7928b9f6e544a9c5a3dbcf..fba6c218fd6edcda5d52d5601fb8f5a976689f8c 100644 (file)
@@ -4228,10 +4228,15 @@ build_stl_str_hl(
     char_u     win_tmp[TMPLEN];
     char_u     *usefmt = fmt;
     stl_hlrec_T *sp;
-    int                save_must_redraw = must_redraw;
-    int                save_redr_type = curwin->w_redr_type;
+    int                save_redraw_not_allowed = redraw_not_allowed;
     int                save_KeyTyped = KeyTyped;
 
+    // When inside update_screen() we do not want redrawing a statusline,
+    // ruler, title, etc. to trigger another redraw, it may cause an endless
+    // loop.
+    if (updating_screen)
+       redraw_not_allowed = TRUE;
+
     if (stl_items == NULL)
     {
        stl_items = ALLOC_MULT(stl_item_T, stl_items_len);
@@ -4968,11 +4973,11 @@ build_stl_str_hl(
        else
            stl_items[curitem].stl_type = Empty;
 
+       if (num >= 0 || (!itemisflag && str != NULL && *str != NUL))
+           prevchar_isflag = FALSE;        // Item not NULL, but not a flag
+                                           //
        if (opt == STL_VIM_EXPR)
            vim_free(str);
-
-       if (num >= 0 || (!itemisflag && str && *str))
-           prevchar_isflag = FALSE;        // Item not NULL, but not a flag
        curitem++;
     }
     *p = NUL;
@@ -5125,13 +5130,7 @@ build_stl_str_hl(
        sp->userhl = 0;
     }
 
-    // When inside update_screen we do not want redrawing a statusline, ruler,
-    // title, etc. to trigger another redraw, it may cause an endless loop.
-    if (updating_screen)
-    {
-       must_redraw = save_must_redraw;
-       curwin->w_redr_type = save_redr_type;
-    }
+    redraw_not_allowed = save_redraw_not_allowed;
 
     // A user function may reset KeyTyped, restore it.
     KeyTyped = save_KeyTyped;
index 9e1c1c9188e2d323118fe36e44d531f1327efe6c..51ffe28524ce21ed5b0fa2451f73ed21c6fd306f 100644 (file)
@@ -559,7 +559,7 @@ changed_common(
            linenr_T last = lnume + xtra - 1;  // last line after the change
 #endif
            // Mark this window to be redrawn later.
-           if (wp->w_redr_type < UPD_VALID)
+           if (!redraw_not_allowed && wp->w_redr_type < UPD_VALID)
                wp->w_redr_type = UPD_VALID;
 
            // Check if a change in the buffer has invalidated the cached
@@ -671,8 +671,7 @@ changed_common(
 
     // Call update_screen() later, which checks out what needs to be redrawn,
     // since it notices b_mod_set and then uses b_mod_*.
-    if (must_redraw < UPD_VALID)
-       must_redraw = UPD_VALID;
+    set_must_redraw(UPD_VALID);
 
     // when the cursor line is changed always trigger CursorMoved
     if (lnum <= curwin->w_cursor.lnum
index de4ff83efb661ec467185c3515ddfba96ca28644..a1ae43a3c763ee85ead6053a13deb69aaa4d578c 100644 (file)
@@ -2028,7 +2028,7 @@ listdigraphs(int use_headers)
 
     // clear screen, because some digraphs may be wrong, in which case we
     // messed up ScreenLines
-    must_redraw = UPD_CLEAR;
+    set_must_redraw(UPD_CLEAR);
 }
 
     static void
index 9e8d9eede1286cb9eec94a617363e8ec2811e360..a9b3643ed8092745d5e155f9468ba9d7474accd5 100644 (file)
@@ -3154,7 +3154,7 @@ redraw_win_later(
     win_T      *wp,
     int                type)
 {
-    if (!exiting && wp->w_redr_type < type)
+    if (!exiting && !redraw_not_allowed && wp->w_redr_type < type)
     {
        wp->w_redr_type = type;
        if (type >= UPD_NOT_VALID)
@@ -3186,7 +3186,17 @@ redraw_all_later(int type)
     FOR_ALL_WINDOWS(wp)
        redraw_win_later(wp, type);
     // This may be needed when switching tabs.
-    if (must_redraw < type)
+    set_must_redraw(type);
+}
+
+/*
+ * Set "must_redraw" to "type" unless it already has a higher value
+ * or it is currently not allowed.
+ */
+    void
+set_must_redraw(int type)
+{
+    if (!redraw_not_allowed && must_redraw < type)
        must_redraw = type;
 }
 
index 902fc2c1a25ce2c9548dc96d382490ee09144f27..382029a65a8652636f30e9a1fccd485609f9ca87 100644 (file)
@@ -7116,7 +7116,7 @@ do_exedit(
 #ifdef FEAT_GUI
                hold_gui_events = 0;
 #endif
-               must_redraw = UPD_CLEAR;
+               set_must_redraw(UPD_CLEAR);
                pending_exmode_active = TRUE;
 
                main_loop(FALSE, TRUE);
index 99ecefbdde65749cab334f226b748545f8e1d69c..3c2d9046667d455f78c08bcb13694d6cfca2390a 100644 (file)
@@ -600,9 +600,13 @@ EXTERN int diff_need_scrollbind INIT(= FALSE);
 #endif
 
 // While redrawing the screen this flag is set.  It means the screen size
-// ('lines' and 'rows') must not be changed.
+// ('lines' and 'rows') must not be changed and prevents recursive updating.
 EXTERN int     updating_screen INIT(= FALSE);
 
+// While computing a statusline and the like we do not want any w_redr_type or
+// must_redraw to be set.
+EXTERN int     redraw_not_allowed INIT(= FALSE);
+
 #ifdef MESSAGE_QUEUE
 // While closing windows or buffers messages should not be handled to avoid
 // using invalid windows or buffers.
index af85c385da9a154475c15451b11ec02cba8e1bf9..9fc2ed9b3664f599ce59e6b1e3a30853b7946e99 100644 (file)
@@ -939,7 +939,7 @@ highlight_set_ctermfg(int idx, int color, int is_normal_group)
        if (!gui.in_use && !gui.starting)
 #endif
        {
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
            if (termcap_active && color >= 0)
                term_fg_color(color);
        }
@@ -962,7 +962,7 @@ highlight_set_ctermbg(int idx, int color, int is_normal_group)
        if (!gui.in_use && !gui.starting)
 #endif
        {
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
            if (color >= 0)
            {
                int dark = -1;
@@ -1005,7 +1005,7 @@ highlight_set_ctermul(int idx, int color, int is_normal_group)
        if (!gui.in_use && !gui.starting)
 #endif
        {
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
            if (termcap_active && color >= 0)
                term_ul_color(color);
        }
@@ -1919,7 +1919,7 @@ set_normal_colors(void)
                                 FALSE, TRUE, FALSE))
        {
            gui_mch_new_colors();
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
        }
 #  ifdef FEAT_GUI_X11
        if (set_group_colors((char_u *)"Menu",
@@ -1929,7 +1929,7 @@ set_normal_colors(void)
 #   ifdef FEAT_MENU
            gui_mch_new_menu_colors();
 #   endif
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
        }
 #   ifdef FEAT_BEVAL_GUI
        if (set_group_colors((char_u *)"Tooltip",
@@ -1939,7 +1939,7 @@ set_normal_colors(void)
 #    ifdef FEAT_TOOLBAR
            gui_mch_new_tooltip_colors();
 #    endif
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
        }
 #   endif
        if (set_group_colors((char_u *)"Scrollbar",
@@ -1947,7 +1947,7 @@ set_normal_colors(void)
                        FALSE, FALSE, FALSE))
        {
            gui_new_scrollbar_colors();
-           must_redraw = UPD_CLEAR;
+           set_must_redraw(UPD_CLEAR);
        }
 #  endif
     }
@@ -1973,7 +1973,7 @@ set_normal_colors(void)
                // color
                cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg;
                cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg;
-               must_redraw = UPD_CLEAR;
+               set_must_redraw(UPD_CLEAR);
            }
        }
     }
@@ -2545,7 +2545,7 @@ get_attr_entry(garray_T *table, attrentry_T *aep)
 
        clear_hl_tables();
 
-       must_redraw = UPD_CLEAR;
+       set_must_redraw(UPD_CLEAR);
 
        for (i = 0; i < highlight_ga.ga_len; ++i)
            set_hl_attr(i);
index c6430aaac5b6b72b56c082b9962ec200fcf8c24e..f4db631a310d33bb2ba5d76a9fd66f459489db0c 100644 (file)
@@ -686,7 +686,7 @@ vim_main2(void)
                        && !gui.in_use
 #endif
                                        )
-       must_redraw = UPD_CLEAR;
+       set_must_redraw(UPD_CLEAR);
     else
     {
        screenclear();                  // clear screen
index 11662ba6a59d398376e3c7f86160b069fa4174a2..46cf1e02722ddba40f2f76c62a6690e55fb284de 100644 (file)
@@ -1143,7 +1143,7 @@ wait_return(int redraw)
     FILE       *save_scriptout;
 
     if (redraw == TRUE)
-       must_redraw = UPD_CLEAR;
+       set_must_redraw(UPD_CLEAR);
 
     // If using ":silent cmd", don't wait for a return.  Also don't set
     // need_wait_return to do it later.
@@ -2490,8 +2490,7 @@ inc_msg_scrolled(void)
     }
 #endif
     ++msg_scrolled;
-    if (must_redraw < UPD_VALID)
-       must_redraw = UPD_VALID;
+    set_must_redraw(UPD_VALID);
 }
 
 /*
index 6b01ef2bba37291b98bff0440e598557ee196abb..638392252166271023539bcbb46f193a7f20301b 100644 (file)
@@ -413,10 +413,8 @@ plines_win_nofold(win_T *wp, linenr_T lnum)
     clear_chartabsize_arg(&cts);
     col = (int)cts.cts_vcol;
 
-    /*
-     * If list mode is on, then the '$' at the end of the line may take up one
-     * extra column.
-     */
+    // If list mode is on, then the '$' at the end of the line may take up one
+    // extra column.
     if (wp->w_p_list && wp->w_lcs_chars.eol != NUL)
        col += 1;
 
@@ -585,8 +583,7 @@ check_status(buf_T *buf)
        if (wp->w_buffer == buf && wp->w_status_height)
        {
            wp->w_redr_status = TRUE;
-           if (must_redraw < UPD_VALID)
-               must_redraw = UPD_VALID;
+           set_must_redraw(UPD_VALID);
        }
 }
 
index c83501986b56648840806e8c6439ccaeb2974057..0f5ff02d274f42f7bda0934f772d796b7a08b91a 100644 (file)
@@ -13,6 +13,7 @@ void redraw_later(int type);
 void redraw_win_later(win_T *wp, int type);
 void redraw_later_clear(void);
 void redraw_all_later(int type);
+void set_must_redraw(int type);
 void redraw_curbuf_later(int type);
 void redraw_buf_later(buf_T *buf, int type);
 void redraw_buf_line_later(buf_T *buf, linenr_T lnum);
index 01a690209c18e9bec42d4e50d9a8477f1c4702c5..abbfc2fe580b4fdc50f10d47ebdba9e025917f86 100644 (file)
@@ -2906,7 +2906,7 @@ give_up:
     screen_Rows = Rows;
     screen_Columns = Columns;
 
-    must_redraw = UPD_CLEAR;   // need to clear the screen later
+    set_must_redraw(UPD_CLEAR);        // need to clear the screen later
     if (doclear)
        screenclear2();
 #ifdef FEAT_GUI
index e2882b67a38b51d5a78cddd6472ce765886c11e6..ec381fef2dc7662abc59884ef529cf84618ecabd 100644 (file)
@@ -731,6 +731,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    245,
 /**/
     244,
 /**/