]> granicus.if.org Git - vim/commitdiff
patch 8.0.1002: unnecessarily updating screen after timer callback v8.0.1002
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Aug 2017 21:43:28 +0000 (23:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Aug 2017 21:43:28 +0000 (23:43 +0200)
Problem:    Unnecessarily updating screen after timer callback.
Solution:   Check if calling the timer sets must_redraw.

src/channel.c
src/ex_cmds2.c
src/proto/screen.pro
src/screen.c
src/terminal.c
src/version.c

index b31d95d41ceb64a769580472f8be6889256e3627..886522bffc6e5e8a34424cfdb64c426795ce09db 100644 (file)
@@ -2887,7 +2887,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
              if (channel_need_redraw)
              {
                  channel_need_redraw = FALSE;
-                 redraw_after_callback();
+                 redraw_after_callback(TRUE);
              }
 
              if (!channel->ch_drop_never)
@@ -4130,7 +4130,7 @@ channel_parse_messages(void)
     if (channel_need_redraw)
     {
        channel_need_redraw = FALSE;
-       redraw_after_callback();
+       redraw_after_callback(TRUE);
     }
 
     --safe_to_invoke_callback;
@@ -5230,7 +5230,7 @@ job_check_ended(void)
     if (channel_need_redraw)
     {
        channel_need_redraw = FALSE;
-       redraw_after_callback();
+       redraw_after_callback(TRUE);
     }
 }
 
index 3682e797abe51c9c554dcb7ee52d6561c2e2a898..18930a6cfb26764d24effa521028387609c7077e 100644 (file)
@@ -1194,6 +1194,7 @@ check_due_timer(void)
     long       next_due = -1;
     proftime_T now;
     int                did_one = FALSE;
+    int                need_update_screen = FALSE;
     long       current_id = last_timer_id;
 # ifdef WIN3264
     LARGE_INTEGER   fr;
@@ -1221,10 +1222,12 @@ check_due_timer(void)
            int did_emsg_save = did_emsg;
            int called_emsg_save = called_emsg;
            int did_throw_save = did_throw;
+           int save_must_redraw = must_redraw;
 
            timer_busy = timer_busy > 0 || vgetc_busy > 0;
            vgetc_busy = 0;
            called_emsg = FALSE;
+           must_redraw = 0;
            timer->tr_firing = TRUE;
            timer_callback(timer);
            timer->tr_firing = FALSE;
@@ -1240,6 +1243,10 @@ check_due_timer(void)
            }
            did_emsg = did_emsg_save;
            called_emsg = called_emsg_save;
+           if (must_redraw != 0)
+               need_update_screen = TRUE;
+           must_redraw = must_redraw > save_must_redraw
+                                             ? must_redraw : save_must_redraw;
 
            /* Only fire the timer again if it repeats and stop_timer() wasn't
             * called while inside the callback (tr_id == -1). */
@@ -1265,7 +1272,7 @@ check_due_timer(void)
     }
 
     if (did_one)
-       redraw_after_callback();
+       redraw_after_callback(need_update_screen);
 
     return current_id != last_timer_id ? 1 : next_due;
 }
index 4e89293bee0067ac9bd1688e3df1bb54a1e6e791..b40e0dadca00c0f52aa66597dbbc91e65a6f9a50 100644 (file)
@@ -7,7 +7,7 @@ void redraw_curbuf_later(int type);
 void redraw_buf_later(buf_T *buf, int type);
 void redraw_buf_and_status_later(buf_T *buf, int type);
 int redraw_asap(int type);
-void redraw_after_callback(void);
+void redraw_after_callback(int call_update_screen);
 void redrawWinline(linenr_T lnum, int invalid);
 void update_curbuf(int type);
 void update_screen(int type_arg);
@@ -47,7 +47,7 @@ void setcursor(void);
 int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear);
 int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr);
 int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp);
-int screen_del_lines(int off, int row, int line_count, int end, int force, int attr, win_T *wp);
+int screen_del_lines(int off, int row, int line_count, int end, int force, int clear_attr, win_T *wp);
 int showmode(void);
 void unshowmode(int force);
 void clearmode(void);
index 54ba9578874d6d4e7f14ff35566943076d415cef..b5762145b71223933a04551b0e5ca37fe81c0d97 100644 (file)
@@ -445,9 +445,11 @@ redraw_asap(int type)
  * Invoked after an asynchronous callback is called.
  * If an echo command was used the cursor needs to be put back where
  * it belongs. If highlighting was changed a redraw is needed.
+ * If "call_update_screen" is FALSE don't call update_screen() when at the
+ * command line.
  */
     void
-redraw_after_callback(void)
+redraw_after_callback(int call_update_screen)
 {
     ++redrawing_for_callback;
 
@@ -461,7 +463,7 @@ redraw_after_callback(void)
 #ifdef FEAT_WILDMENU
                && wild_menu_showing == 0
 #endif
-               )
+               && call_update_screen)
            update_screen(0);
        /* Redraw in the same position, so that the user can continue
         * editing the command. */
@@ -3013,7 +3015,7 @@ win_line(
     int                startrow,
     int                endrow,
     int                nochange UNUSED,        /* not updating for changed text */
-    proftime_T *syntax_tm)
+    proftime_T *syntax_tm UNUSED)
 {
     int                col = 0;                /* visual column on screen */
     unsigned   off;                    /* offset in ScreenLines/ScreenAttrs */
index c5226134c617a378013c49e6b66cd8d63d5bc651..a8c7ae59de13334270ce48bacc8fa0e9eca8793f 100644 (file)
@@ -669,7 +669,7 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
            update_cursor(term, TRUE);
        }
        else
-           redraw_after_callback();
+           redraw_after_callback(TRUE);
     }
 }
 
index f8eb49111e514276d1a157cb7c76dc47f5ed22a0..d79f429bb54170a4d07ec2c892c0432b92b7881f 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1002,
 /**/
     1001,
 /**/