patch 9.2.0261: terminal: redraws are slow
Commit:
https://github.com/vim/vim/commit/54b6c0c0e7191105c80987297bd0e1ad2bc009dc
Author: Yasuhiro Matsumoto <
matt...@gmail.com>
Date: Thu Mar 26 22:12:52 2026 +0000
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 <
matt...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/terminal.c b/src/terminal.c
index e9259947d..8140da55f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -3326,7 +3326,9 @@ handle_movecursor(
position_cursor(wp, &pos);
}
if (term->tl_buffer == curbuf && !term->tl_normal_mode)
- update_cursor(term, term->tl_cursor_visible);
+ // Don't redraw here, it will be done after
+ // vterm_input_write() is finished.
+ update_cursor(term, FALSE);
return 1;
}
@@ -4956,6 +4958,7 @@ create_vterm(term_T *term, int rows, int cols)
}
vterm_screen_set_callbacks(screen, &screen_callbacks, term);
+ vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_SCROLL);
// TODO: depends on 'encoding'.
vterm_set_utf8(vterm, 1);
diff --git a/src/version.c b/src/version.c
index cac2d1837..2dae07da4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 261,
/**/
260,
/**/