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 /runtime/lua/vim/loader.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 'runtime/lua/vim/loader.lua')
| -rw-r--r-- | runtime/lua/vim/loader.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua index bba42e7123..924503514b 100644 --- a/runtime/lua/vim/loader.lua +++ b/runtime/lua/vim/loader.lua @@ -452,7 +452,8 @@ function M.enable(enable) end else _G.loadfile = _loadfile - for l, loader in ipairs(loaders) do + for l = #loaders, 1, -1 do + local loader = loaders[l] if loader == loader_cached or loader == loader_lib_cached then table.remove(loaders, l) end |