mirror of
https://github.com/neovim/neovim.git
synced 2026-09-03 12:50:36 +00:00
fix(loader): remove all cached loaders on disable #41613
Problem: When disabling, the loader list is traversed forwards while entries are removed. As a result, some entries are skipped and remain active. Thus, disabling `vim.loader` restores `_G.loadfile`, but does not fully restore the original package loader chain. Solution: Traverse `package.loaders` in reverse when removing cached loaders. Capture the original `package.loaders` list in the test, and assert that the list is restored properly.
This commit is contained in:
committed by
GitHub
parent
350fa5ad7c
commit
5bc7dbb13e
@@ -14,10 +14,12 @@ describe('vim.loader', function()
|
||||
it('can be disabled', function()
|
||||
exec_lua(function()
|
||||
local orig_loader = _G.loadfile
|
||||
local orig_loaders = { unpack(package.loaders) }
|
||||
vim.loader.enable()
|
||||
assert(orig_loader ~= _G.loadfile)
|
||||
vim.loader.enable(false)
|
||||
assert(orig_loader == _G.loadfile)
|
||||
assert(vim.deep_equal(orig_loaders, package.loaders))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user