[vim/vim] fix(terminal): avoid redundant gui_mch_flush() in conpty terminal (PR #19846)

1 view
Skip to first unread message

mattn

unread,
Mar 27, 2026, 10:26:44 AM (19 hours ago) Mar 27
to vim/vim, Subscribed

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 positioning sequences 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.

vterm_input_write profiling (per 4KB chunk):

Before After Improvement
vterm_input_write 80-110ms 0.7-1.1ms ~100x

Benchmark: 24-line :terminal running dir /s C:\Windows\System32:

Before After Improvement
vim.exe (TUI) 18.73s 18.55s (noise)
gvim.exe (GUI) 68.77s 9.24s -87%

Closes #19845


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19846

Commit Summary

  • f045065 fix(terminal): avoid redundant gui_mch_flush() during vterm_input_write()

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19846@github.com>

Christian Brabandt

unread,
Mar 27, 2026, 11:37:00 AM (18 hours ago) Mar 27
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19846)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19846/c4143471826@github.com>

Christian Brabandt

unread,
Mar 27, 2026, 11:47:15 AM (17 hours ago) Mar 27
to vim/vim, Subscribed

Closed #19846 via 54b6c0c.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19846/issue_event/23976933212@github.com>

Reply all
Reply to author
Forward
0 new messages