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

FAILED   test/functional/terminal/cursor_spec.lua @ 419: :terminal cursor uses the correct attributes
test/functional/terminal/cursor_spec.lua:448: Expected objects to be the same.
Passed in:
(string) 'block'
Expected:
(string) 'vertical'
stack traceback:
	test/functional/terminal/cursor_spec.lua:448: in function <test/functional/terminal/cursor_spec.lua:419>
This commit is contained in:
zeertzjq
2026-04-02 22:22:18 +08:00
committed by GitHub
parent 028805ccbb
commit 596a7a32f3

View File

@@ -425,29 +425,39 @@ describe(':terminal cursor', function()
let chan2 = nvim_open_term(0, {})
]])
feed('i')
screen:expect([[
local s0 = [[
^ │ |
│ |*4
{120:[Scratch] [-] }{119:[Scratch] [-] }|
{5:-- TERMINAL --} |
]])
]]
screen:expect(s0)
eq('block', screen._mode_info[terminal_mode_idx].cursor_shape)
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
-- Modify cursor in the non-current terminal; should not affect this cursor.
command([[call chansend(chan1, "\e[4 q")]])
screen:expect_unchanged()
eq('block', screen._mode_info[terminal_mode_idx].cursor_shape)
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
screen:expect({
grid = s0,
unchanged = true,
condition = function()
eq('block', screen._mode_info[terminal_mode_idx].cursor_shape)
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
end,
})
-- Modify cursor in the current terminal.
command([[call chansend(chan2, "\e[6 q")]])
screen:expect_unchanged()
eq('vertical', screen._mode_info[terminal_mode_idx].cursor_shape)
eq(0, screen._mode_info[terminal_mode_idx].blinkon)
eq(0, screen._mode_info[terminal_mode_idx].blinkoff)
screen:expect({
grid = s0,
condition = function()
eq('vertical', screen._mode_info[terminal_mode_idx].cursor_shape)
eq(0, screen._mode_info[terminal_mode_idx].blinkon)
eq(0, screen._mode_info[terminal_mode_idx].blinkoff)
end,
})
-- Check the cursor in the other terminal reflects our changes from before.
command('wincmd p')