commit cb77bd1b861aa4cb0c99c01efeb26e790263e219
parent 295fb3fdb2a359febc2e75e4eb0f9f438775ab05
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sat, 10 Jan 2026 12:12:06 +0800
test(server_notifications_spec): improve chanclose test (#37337)
Check that a pending event is actually cancelled, in place of the
nvim_subscribe that was removed in #28487.
Diffstat:
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua
@@ -80,23 +80,25 @@ describe('notify', function()
it('cancels stale events on channel close #13537', function()
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
local catpath = eval('exepath("cat")')
+ api.nvim_set_var('somevar', 0)
eq(
{ id = catchan, argv = { catpath }, stream = 'job', mode = 'rpc', client = {} },
- exec_lua(
- [[
- vim.rpcnotify(..., "nvim_call_function", 'chanclose', {..., 'rpc'})
- return vim.api.nvim_get_chan_info(...)
- ]],
- catchan
- )
+ exec_lua(function()
+ vim.rpcnotify(catchan, 'nvim_call_function', 'chanclose', { catchan, 'rpc' })
+ vim.rpcnotify(catchan, 'nvim_set_var', 'somevar', 1) -- Should be cancelled.
+ return vim.api.nvim_get_chan_info(catchan)
+ end)
)
assert_alive()
eq(
{ false, 'Invalid channel: ' .. catchan },
- exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)
+ exec_lua(function()
+ return { pcall(vim.rpcrequest, catchan, 'nvim_eval', '1+1') }
+ end, catchan)
)
retry(nil, 3000, function()
eq({}, api.nvim_get_chan_info(catchan))
end) -- cat be dead :(
+ eq(0, api.nvim_get_var('somevar'))
end)
end)