test(terminal/cursor_spec): fix flaky test (#37715)

Problem:  Cursor visibility test may fail if the :sleep lasts too long.
Solution: Wait for the TermLeave autocommand to finish.
(cherry picked from commit b95e0a8d20)
This commit is contained in:
zeertzjq
2026-02-05 14:27:15 +08:00
committed by github-actions[bot]
parent ba7456b91a
commit a3c8c593f2

View File

@@ -155,13 +155,19 @@ describe(':terminal cursor', function()
-- Cursor is hidden; now request to show it while in a TermLeave autocmd.
-- Process events (via :sleep) to handle the escape sequence now.
command([[autocmd TermLeave * ++once call chansend(&channel, "\e[?25h") | sleep 1m]])
n.exec([[
autocmd TermLeave * ++once call chansend(&channel, "\e[?25h") | sleep 1m
\ | let g:did_termleave = 1]])
feed([[<C-\><C-N>]]) -- Exit terminal mode; cursor should not remain hidden
screen:expect([[
tty ready |
^ |
|*5
]])
-- Wait for the TermLeave autocommand to finish. Sometimes :sleep can be slow.
retry(nil, 1000, function()
eq(1, api.nvim_get_var('did_termleave'))
end)
command('bwipeout! | let chan = nvim_open_term(0, {})')
feed('i')