Skip to content

Commit 54b6c0c

Browse files
mattnchrisbra
authored andcommitted
patch 9.2.0261: terminal: redraws are slow
Problem: terminal: redraws are slow (Mao-Yining) Solution: Disable redrawing in handle_movecursor() (Yasuhiro Matsumoto) handle_movecursor callback was calling update_cursor() with redraw=TRUE on every cursor move inside vterm_input_write(). This triggered gui_mch_flush() (GdiFlush + DWriteContext_Flush) and TextChangedT autocmd for each cursor move. ConPTY output contains ~17 cursor moves per 4KB chunk, each flush taking ~5ms, resulting in 80-110ms per chunk. Fix by passing FALSE to update_cursor() in handle_movecursor since write_to_term() already calls update_cursor() with proper redraw after vterm_input_write() finishes. Also set vterm_screen_set_damage_merge() to VTERM_DAMAGE_SCROLL so that damage callbacks are buffered until vterm_screen_flush_damage() instead of being emitted per cell. fixes: #19845 closes: #19846 Signed-off-by: Yasuhiro Matsumoto <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 575961c commit 54b6c0c

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/terminal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,9 @@ handle_movecursor(
33263326
position_cursor(wp, &pos);
33273327
}
33283328
if (term->tl_buffer == curbuf && !term->tl_normal_mode)
3329-
update_cursor(term, term->tl_cursor_visible);
3329+
// Don't redraw here, it will be done after
3330+
// vterm_input_write() is finished.
3331+
update_cursor(term, FALSE);
33303332

33313333
return 1;
33323334
}
@@ -4956,6 +4958,7 @@ create_vterm(term_T *term, int rows, int cols)
49564958
}
49574959

49584960
vterm_screen_set_callbacks(screen, &screen_callbacks, term);
4961+
vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_SCROLL);
49594962
// TODO: depends on 'encoding'.
49604963
vterm_set_utf8(vterm, 1);
49614964

src/version.c

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

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
261,
737739
/**/
738740
260,
739741
/**/

0 commit comments

Comments
 (0)