@@ -2493,6 +2493,41 @@ describe('lua stdlib', function()
2493
2493
2494
2494
eq (false , pcall_result )
2495
2495
end )
2496
+
2497
+ describe (' returns -2 when interrupted' , function ()
2498
+ before_each (function ()
2499
+ local channel = meths .get_api_info ()[1 ]
2500
+ meths .set_var (' channel' , channel )
2501
+ end )
2502
+
2503
+ it (' without callback' , function ()
2504
+ exec_lua ([[
2505
+ function _G.Wait()
2506
+ vim.rpcnotify(vim.g.channel, 'ready')
2507
+ local _, interrupted = vim.wait(4000)
2508
+ vim.rpcnotify(vim.g.channel, 'wait', interrupted)
2509
+ end
2510
+ ]] )
2511
+ feed (' :lua _G.Wait()<CR>' )
2512
+ eq ({' notification' , ' ready' , {}}, next_msg (500 ))
2513
+ feed (' <C-C>' )
2514
+ eq ({' notification' , ' wait' , {- 2 }}, next_msg (500 ))
2515
+ end )
2516
+
2517
+ it (' with callback' , function ()
2518
+ exec_lua ([[
2519
+ function _G.Wait()
2520
+ vim.rpcnotify(vim.g.channel, 'ready')
2521
+ local _, interrupted = vim.wait(4000, function() end)
2522
+ vim.rpcnotify(vim.g.channel, 'wait', interrupted)
2523
+ end
2524
+ ]] )
2525
+ feed (' :lua _G.Wait()<CR>' )
2526
+ eq ({' notification' , ' ready' , {}}, next_msg (500 ))
2527
+ feed (' <C-C>' )
2528
+ eq ({' notification' , ' wait' , {- 2 }}, next_msg (500 ))
2529
+ end )
2530
+ end )
2496
2531
end )
2497
2532
2498
2533
it (' vim.notify_once' , function ()
0 commit comments