Skip to content

Commit ebec3e2

Browse files
committed
patch 8.2.2064: terminal: cursor is on while redrawing, causing flicker
Problem: terminal: cursor is on while redrawing, causing flicker. Solution: Switch the cursor off while redrawing. Always add the top and left offset to the cursor position when not done already. (closes #5943)
1 parent dc234ca commit ebec3e2

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/popupwin.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,9 @@ update_popups(void (*win_update)(win_T *wp))
36993699
int attr_scroll = 0;
37003700
int attr_thumb = 0;
37013701

3702+
// hide the cursor until redrawing is done.
3703+
cursor_off();
3704+
37023705
// Find the window with the lowest zindex that hasn't been updated yet,
37033706
// so that the window with a higher zindex is drawn later, thus goes on
37043707
// top.

src/terminal.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
12021202
return;
12031203
}
12041204
ch_log(channel, "writing %d bytes to terminal", (int)len);
1205+
cursor_off();
12051206
term_write_job_output(term, msg, len);
12061207

12071208
#ifdef FEAT_GUI
@@ -2199,15 +2200,17 @@ send_keys_to_term(term_T *term, int c, int modmask, int typed)
21992200
}
22002201

22012202
static void
2202-
position_cursor(win_T *wp, VTermPos *pos, int add_off UNUSED)
2203+
position_cursor(win_T *wp, VTermPos *pos)
22032204
{
22042205
wp->w_wrow = MIN(pos->row, MAX(0, wp->w_height - 1));
22052206
wp->w_wcol = MIN(pos->col, MAX(0, wp->w_width - 1));
22062207
#ifdef FEAT_PROP_POPUP
2207-
if (add_off && popup_is_popup(curwin))
2208+
if (popup_is_popup(wp))
22082209
{
2209-
wp->w_wrow += popup_top_extra(curwin);
2210-
wp->w_wcol += popup_left_extra(curwin);
2210+
if ((wp->w_flags & WFLAG_WROW_OFF_ADDED) == 0)
2211+
wp->w_wrow += popup_top_extra(wp);
2212+
if ((wp->w_flags & WFLAG_WCOL_OFF_ADDED) == 0)
2213+
wp->w_wcol += popup_left_extra(wp);
22112214
wp->w_flags |= WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED;
22122215
}
22132216
else
@@ -2524,7 +2527,7 @@ terminal_loop(int blocking)
25242527
if (termwinkey == Ctrl_W)
25252528
termwinkey = 0;
25262529
}
2527-
position_cursor(curwin, &curbuf->b_term->tl_cursor_pos, TRUE);
2530+
position_cursor(curwin, &curbuf->b_term->tl_cursor_pos);
25282531
may_set_cursor_props(curbuf->b_term);
25292532

25302533
while (blocking || vpeekc_nomap() != NUL)
@@ -3059,13 +3062,10 @@ handle_movecursor(
30593062
while (for_all_windows_and_curwin(&wp, &did_curwin))
30603063
{
30613064
if (wp->w_buffer == term->tl_buffer)
3062-
position_cursor(wp, &pos, FALSE);
3065+
position_cursor(wp, &pos);
30633066
}
30643067
if (term->tl_buffer == curbuf && !term->tl_normal_mode)
3065-
{
3066-
may_toggle_cursor(term);
30673068
update_cursor(term, term->tl_cursor_visible);
3068-
}
30693069

30703070
return 1;
30713071
}
@@ -3818,7 +3818,7 @@ term_update_window(win_T *wp)
38183818

38193819
// The cursor may have been moved when resizing.
38203820
vterm_state_get_cursorpos(state, &pos);
3821-
position_cursor(wp, &pos, FALSE);
3821+
position_cursor(wp, &pos);
38223822

38233823
for (pos.row = term->tl_dirty_row_start; pos.row < term->tl_dirty_row_end
38243824
&& pos.row < wp->w_height; ++pos.row)

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2064,
753755
/**/
754756
2063,
755757
/**/

0 commit comments

Comments
 (0)