]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.1419: listener callbacks may be called recursively v8.1.1419
authorBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 20:28:29 +0000 (22:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 20:28:29 +0000 (22:28 +0200)
Problem:    Listener callbacks may be called recursively.
Solution:   Set "updating_screen" while listener callbacks are invoked.

src/change.c
src/proto/screen.pro
src/screen.c
src/ui.c
src/version.c

index 11f4b0a169b8a12e5b73a4ccd3842a4d2b835cbe..b1a56ae4c00facdb78430ff7596a94d1173d82b5 100644 (file)
@@ -376,10 +376,18 @@ invoke_listeners(buf_T *buf)
     linenr_T   start = MAXLNUM;
     linenr_T   end = 0;
     linenr_T   added = 0;
+    int                save_updating_screen = updating_screen;
+    static int recursive = FALSE;
 
     if (buf->b_recorded_changes == NULL  // nothing changed
-           || buf->b_listener == NULL)  // no listeners
+           || buf->b_listener == NULL   // no listeners
+           || recursive)                // already busy
        return;
+    recursive = TRUE;
+
+    // Block messages on channels from being handled, so that they don't make
+    // text changes here.
+    ++updating_screen;
 
     argv[0].v_type = VAR_NUMBER;
     argv[0].vval.v_number = buf->b_fnum; // a:bufnr
@@ -418,6 +426,12 @@ invoke_listeners(buf_T *buf)
     --textlock;
     list_unref(buf->b_recorded_changes);
     buf->b_recorded_changes = NULL;
+
+    if (save_updating_screen)
+       updating_screen = TRUE;
+    else
+       after_updating_screen(TRUE);
+    recursive = FALSE;
 }
 #endif
 
index 0657831db6641897a85c30652d2852b8399cc5f1..ab73e0ba9b88c244e7c7daa21a22dbbed9514dec 100644 (file)
@@ -10,7 +10,7 @@ void redraw_buf_and_status_later(buf_T *buf, int type);
 int redraw_asap(int type);
 void redraw_after_callback(int call_update_screen);
 void redrawWinline(win_T *wp, linenr_T lnum);
-void reset_updating_screen(int may_resize_shell);
+void after_updating_screen(int may_resize_shell);
 void update_curbuf(int type);
 int update_screen(int type_arg);
 int conceal_cursor_line(win_T *wp);
@@ -18,7 +18,7 @@ void conceal_check_cursor_line(void);
 void update_debug_sign(buf_T *buf, linenr_T lnum);
 void updateWindow(win_T *wp);
 int screen_get_current_line_off(void);
-void screen_line(int row, int coloff, int endcol, int clear_width, int rlflag);
+void screen_line(int row, int coloff, int endcol, int clear_width, int flags);
 void rl_mirror(char_u *str);
 void status_redraw_all(void);
 void status_redraw_curbuf(void);
index d20bd2a7b62e9d2c5e59e48f65af296cbde7dde7..de0833a679538b3c4c392017ff9ce623acedb088 100644 (file)
@@ -506,8 +506,12 @@ redrawWinline(
     redraw_win_later(wp, VALID);
 }
 
+/*
+ * To be called when "updating_screen" was set before and now the postponed
+ * side effects may take place.
+ */
     void
-reset_updating_screen(int may_resize_shell UNUSED)
+after_updating_screen(int may_resize_shell UNUSED)
 {
     updating_screen = FALSE;
 #ifdef FEAT_GUI
@@ -803,7 +807,7 @@ update_screen(int type_arg)
     FOR_ALL_WINDOWS(wp)
        wp->w_buffer->b_mod_set = FALSE;
 
-    reset_updating_screen(TRUE);
+    after_updating_screen(TRUE);
 
     /* Clear or redraw the command line.  Done last, because scrolling may
      * mess up the command line. */
@@ -886,7 +890,7 @@ update_finish(void)
     end_search_hl();
 # endif
 
-    reset_updating_screen(TRUE);
+    after_updating_screen(TRUE);
 
 # ifdef FEAT_GUI
     /* Redraw the cursor and update the scrollbars when all screen updating is
index ac0cc27085bcd664dc33e665037f6f426941e4b0..ed0e50abe0ba51af30cee343a6d207181f37780d 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -691,7 +691,7 @@ ui_breakcheck_force(int force)
     if (save_updating_screen)
        updating_screen = TRUE;
     else
-       reset_updating_screen(FALSE);
+       after_updating_screen(FALSE);
 
     recursive = FALSE;
 }
index 511b28b5f0bda4b93cb22da1c415eb45355019da..089b44f2bbf7db7ddba0074f389e5b263e263e25 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1419,
 /**/
     1418,
 /**/