Skip to content

Commit 02e177d

Browse files
committed
patch 8.0.1002: unnecessarily updating screen after timer callback
Problem: Unnecessarily updating screen after timer callback. Solution: Check if calling the timer sets must_redraw.
1 parent 0903d56 commit 02e177d

6 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/channel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,7 +2887,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
28872887
if (channel_need_redraw)
28882888
{
28892889
channel_need_redraw = FALSE;
2890-
redraw_after_callback();
2890+
redraw_after_callback(TRUE);
28912891
}
28922892

28932893
if (!channel->ch_drop_never)
@@ -4130,7 +4130,7 @@ channel_parse_messages(void)
41304130
if (channel_need_redraw)
41314131
{
41324132
channel_need_redraw = FALSE;
4133-
redraw_after_callback();
4133+
redraw_after_callback(TRUE);
41344134
}
41354135

41364136
--safe_to_invoke_callback;
@@ -5230,7 +5230,7 @@ job_check_ended(void)
52305230
if (channel_need_redraw)
52315231
{
52325232
channel_need_redraw = FALSE;
5233-
redraw_after_callback();
5233+
redraw_after_callback(TRUE);
52345234
}
52355235
}
52365236

src/ex_cmds2.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,7 @@ check_due_timer(void)
11941194
long next_due = -1;
11951195
proftime_T now;
11961196
int did_one = FALSE;
1197+
int need_update_screen = FALSE;
11971198
long current_id = last_timer_id;
11981199
# ifdef WIN3264
11991200
LARGE_INTEGER fr;
@@ -1221,10 +1222,12 @@ check_due_timer(void)
12211222
int did_emsg_save = did_emsg;
12221223
int called_emsg_save = called_emsg;
12231224
int did_throw_save = did_throw;
1225+
int save_must_redraw = must_redraw;
12241226

12251227
timer_busy = timer_busy > 0 || vgetc_busy > 0;
12261228
vgetc_busy = 0;
12271229
called_emsg = FALSE;
1230+
must_redraw = 0;
12281231
timer->tr_firing = TRUE;
12291232
timer_callback(timer);
12301233
timer->tr_firing = FALSE;
@@ -1240,6 +1243,10 @@ check_due_timer(void)
12401243
}
12411244
did_emsg = did_emsg_save;
12421245
called_emsg = called_emsg_save;
1246+
if (must_redraw != 0)
1247+
need_update_screen = TRUE;
1248+
must_redraw = must_redraw > save_must_redraw
1249+
? must_redraw : save_must_redraw;
12431250

12441251
/* Only fire the timer again if it repeats and stop_timer() wasn't
12451252
* called while inside the callback (tr_id == -1). */
@@ -1265,7 +1272,7 @@ check_due_timer(void)
12651272
}
12661273

12671274
if (did_one)
1268-
redraw_after_callback();
1275+
redraw_after_callback(need_update_screen);
12691276

12701277
return current_id != last_timer_id ? 1 : next_due;
12711278
}

src/proto/screen.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void redraw_curbuf_later(int type);
77
void redraw_buf_later(buf_T *buf, int type);
88
void redraw_buf_and_status_later(buf_T *buf, int type);
99
int redraw_asap(int type);
10-
void redraw_after_callback(void);
10+
void redraw_after_callback(int call_update_screen);
1111
void redrawWinline(linenr_T lnum, int invalid);
1212
void update_curbuf(int type);
1313
void update_screen(int type_arg);
@@ -47,7 +47,7 @@ void setcursor(void);
4747
int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear);
4848
int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr);
4949
int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp);
50-
int screen_del_lines(int off, int row, int line_count, int end, int force, int attr, win_T *wp);
50+
int screen_del_lines(int off, int row, int line_count, int end, int force, int clear_attr, win_T *wp);
5151
int showmode(void);
5252
void unshowmode(int force);
5353
void clearmode(void);

src/screen.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,11 @@ redraw_asap(int type)
445445
* Invoked after an asynchronous callback is called.
446446
* If an echo command was used the cursor needs to be put back where
447447
* it belongs. If highlighting was changed a redraw is needed.
448+
* If "call_update_screen" is FALSE don't call update_screen() when at the
449+
* command line.
448450
*/
449451
void
450-
redraw_after_callback(void)
452+
redraw_after_callback(int call_update_screen)
451453
{
452454
++redrawing_for_callback;
453455

@@ -461,7 +463,7 @@ redraw_after_callback(void)
461463
#ifdef FEAT_WILDMENU
462464
&& wild_menu_showing == 0
463465
#endif
464-
)
466+
&& call_update_screen)
465467
update_screen(0);
466468
/* Redraw in the same position, so that the user can continue
467469
* editing the command. */
@@ -3013,7 +3015,7 @@ win_line(
30133015
int startrow,
30143016
int endrow,
30153017
int nochange UNUSED, /* not updating for changed text */
3016-
proftime_T *syntax_tm)
3018+
proftime_T *syntax_tm UNUSED)
30173019
{
30183020
int col = 0; /* visual column on screen */
30193021
unsigned off; /* offset in ScreenLines/ScreenAttrs */

src/terminal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
669669
update_cursor(term, TRUE);
670670
}
671671
else
672-
redraw_after_callback();
672+
redraw_after_callback(TRUE);
673673
}
674674
}
675675

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1002,
772774
/**/
773775
1001,
774776
/**/

0 commit comments

Comments
 (0)