aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorVolodymyr Chernetskyi <volodymyr_chernetskyi@goodyear.com>2026-09-02 16:08:37 +0200
committerGitHub <noreply@github.com>2026-09-02 10:08:37 -0400
commit5bc7dbb13ecb644e9cff2468503f826cfca01483 (patch)
treee1ff5eb86b6c18c436060759e31e97f7f70e63f5 /runtime/lua/vim
parent350fa5ad7ccc014bcdd0eea2bd76ba09a265452e (diff)
downloadrneovim-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')
-rw-r--r--runtime/lua/vim/loader.lua3
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