To: vim_dev@googlegroups.com Subject: Patch 8.0.1001 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1002 Problem: Unnecessarily updating screen after timer callback. Solution: Check if calling the timer sets must_redraw. Files: src/ex_cmds2.c, src/channel.c, src/screen.c, src/proto/screen.pro, src/terminal.c *** ../vim-8.0.1001/src/ex_cmds2.c 2017-08-21 22:05:58.152654756 +0200 --- src/ex_cmds2.c 2017-08-26 23:34:08.406320274 +0200 *************** *** 1194,1199 **** --- 1194,1200 ---- 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,1230 **** --- 1222,1233 ---- 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,1245 **** --- 1243,1252 ---- } 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,1271 **** } if (did_one) ! redraw_after_callback(); return current_id != last_timer_id ? 1 : next_due; } --- 1272,1278 ---- } if (did_one) ! redraw_after_callback(need_update_screen); return current_id != last_timer_id ? 1 : next_due; } *** ../vim-8.0.1001/src/channel.c 2017-08-26 22:02:45.869432874 +0200 --- src/channel.c 2017-08-26 23:34:37.702142588 +0200 *************** *** 2887,2893 **** if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(); } if (!channel->ch_drop_never) --- 2887,2893 ---- if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(TRUE); } if (!channel->ch_drop_never) *************** *** 4130,4136 **** if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(); } --safe_to_invoke_callback; --- 4130,4136 ---- if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(TRUE); } --safe_to_invoke_callback; *************** *** 5230,5236 **** if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(); } } --- 5230,5236 ---- if (channel_need_redraw) { channel_need_redraw = FALSE; ! redraw_after_callback(TRUE); } } *** ../vim-8.0.1001/src/screen.c 2017-08-17 20:31:44.001203501 +0200 --- src/screen.c 2017-08-26 23:35:57.349659241 +0200 *************** *** 445,453 **** * 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. */ void ! redraw_after_callback(void) { ++redrawing_for_callback; --- 445,455 ---- * 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(int call_update_screen) { ++redrawing_for_callback; *************** *** 461,467 **** #ifdef FEAT_WILDMENU && wild_menu_showing == 0 #endif ! ) update_screen(0); /* Redraw in the same position, so that the user can continue * editing the command. */ --- 463,469 ---- #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,3019 **** int startrow, int endrow, int nochange UNUSED, /* not updating for changed text */ ! proftime_T *syntax_tm) { int col = 0; /* visual column on screen */ unsigned off; /* offset in ScreenLines/ScreenAttrs */ --- 3015,3021 ---- int startrow, int endrow, int nochange UNUSED, /* not updating for changed text */ ! proftime_T *syntax_tm UNUSED) { int col = 0; /* visual column on screen */ unsigned off; /* offset in ScreenLines/ScreenAttrs */ *** ../vim-8.0.1001/src/proto/screen.pro 2017-08-17 20:31:44.001203501 +0200 --- src/proto/screen.pro 2017-08-26 23:37:19.601159684 +0200 *************** *** 7,13 **** 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 redrawWinline(linenr_T lnum, int invalid); void update_curbuf(int type); void update_screen(int type_arg); --- 7,13 ---- 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(int call_update_screen); void redrawWinline(linenr_T lnum, int invalid); void update_curbuf(int type); void update_screen(int type_arg); *************** *** 47,53 **** 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 showmode(void); void unshowmode(int force); void clearmode(void); --- 47,53 ---- 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 clear_attr, win_T *wp); int showmode(void); void unshowmode(int force); void clearmode(void); *** ../vim-8.0.1001/src/terminal.c 2017-08-26 22:02:45.865432901 +0200 --- src/terminal.c 2017-08-26 23:36:57.109296331 +0200 *************** *** 669,675 **** update_cursor(term, TRUE); } else ! redraw_after_callback(); } } --- 669,675 ---- update_cursor(term, TRUE); } else ! redraw_after_callback(TRUE); } } *** ../vim-8.0.1001/src/version.c 2017-08-26 22:30:10.994510924 +0200 --- src/version.c 2017-08-26 23:38:25.368756941 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1002, /**/ -- How To Keep A Healthy Level Of Insanity: 4. Put your garbage can on your desk and label it "in". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///