From a3c8c593f2b017296bcece539d5da94e2143044e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 5 Feb 2026 14:27:15 +0800 Subject: [PATCH] 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 b95e0a8d20b73ec1989a373b76b9b0e828ad540f) --- test/functional/terminal/cursor_spec.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 474e14ea57..af6d418460 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -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([[]]) -- 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')