fix(lua): vim.regex():match_str abort in Luv callback #41008

(cherry picked from commit 80cd482577)
This commit is contained in:
Justin M. Keyes
2026-07-27 07:01:54 -04:00
committed by github-actions[bot]
parent b6832a53b4
commit 69e2fc26f0
4 changed files with 32 additions and 5 deletions

View File

@@ -1818,6 +1818,29 @@ describe('lua stdlib', function()
-- vim.regex() error inside :silent! should not crash. #20546
command([[silent! lua vim.regex('\\z')]])
assert_alive()
-- match_str() in a fast (luv) callback does not abort. #18111
eq(
{ true, true },
exec_lua(function()
local re = vim.regex('^.*\\.go$')
local res
local timer = assert(vim.uv.new_timer())
timer:start(10, 0, function()
-- Enough matches to reach BREAKCHECK_SKIP, which would abort (reentrant event loop).
local ok = true
for _ = 1, 3000 do
ok = ok and re:match_str('internal/config/config.go') ~= nil
end
res = { ok, vim.in_fast_event() }
timer:close()
end)
vim.wait(1000, function()
return res ~= nil
end)
return res
end)
)
end)
it('vim.defer_fn', function()