]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0261: terminal: redraws are slow v9.2.0261
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Thu, 26 Mar 2026 22:12:52 +0000 (22:12 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 26 Mar 2026 22:12:52 +0000 (22:12 +0000)
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 <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/terminal.c
src/version.c

index e9259947d2d34ca9a2f324d58f225e13e0213d06..8140da55f21ec0558c4f26e9828b5f5bcdcd1b96 100644 (file)
@@ -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);
 
index cac2d18371bf1012c4e7f4293600b567a76344cf..2dae07da4c17b25093160cae1eae7f5cd117ad95 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    261,
 /**/
     260,
 /**/