fix: wait() checks condition twice on each interval (#37837)

Problem:  wait() checks condition twice on each interval.
Solution: Don't schedule the due callback. Also fix memory leak when
          Nvim exits while waiting.

No test that the condition isn't checked twice, as testing for that can
be flaky when there are libuv events from other sources.
This commit is contained in:
zeertzjq
2026-02-13 21:02:40 +08:00
committed by GitHub
parent a7a7cdbcda
commit 9c5ade9212
4 changed files with 41 additions and 10 deletions

View File

@@ -2379,6 +2379,15 @@ stack traceback:
)
end)
it('does not leak when Nvim exits while waiting', function()
n.expect_exit(500, exec_lua, function()
vim.defer_fn(function()
vim.cmd('qall!')
end, 10)
vim.wait(10000)
end)
end)
it('plays nice with `not` when fails', function()
eq(
true,