diff options
| author | Volodymyr Chernetskyi <volodymyr_chernetskyi@goodyear.com> | 2026-09-02 16:08:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-02 10:08:37 -0400 |
| commit | 5bc7dbb13ecb644e9cff2468503f826cfca01483 (patch) | |
| tree | e1ff5eb86b6c18c436060759e31e97f7f70e63f5 /test/functional/lua/loader_spec.lua | |
| parent | 350fa5ad7ccc014bcdd0eea2bd76ba09a265452e (diff) | |
| download | rneovim-5bc7dbb13ecb644e9cff2468503f826cfca01483.tar.gz rneovim-5bc7dbb13ecb644e9cff2468503f826cfca01483.tar.bz2 rneovim-5bc7dbb13ecb644e9cff2468503f826cfca01483.zip | |
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.
Diffstat (limited to 'test/functional/lua/loader_spec.lua')
| -rw-r--r-- | test/functional/lua/loader_spec.lua | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/functional/lua/loader_spec.lua b/test/functional/lua/loader_spec.lua index 8ddd5c9684..0ce19766dd 100644 --- a/test/functional/lua/loader_spec.lua +++ b/test/functional/lua/loader_spec.lua @@ -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) |