Skip to content

Commit 5128d89

Browse files
committed
fix: destroy the cache when VIMRUNTIME has changed
1 parent 72f64ce commit 5128d89

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/lazy/core/cache.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ end
155155

156156
function M.save_cache()
157157
local f = assert(uv.fs_open(M.config.path, "w", 438))
158+
uv.fs_write(f, vim.env.VIMRUNTIME)
159+
uv.fs_write(f, "\0")
158160
for modname, entry in pairs(M.cache) do
159161
if entry.used > os.time() - M.ttl then
160162
entry.modname = modname
@@ -184,7 +186,16 @@ function M.load_cache()
184186
local data = uv.fs_read(f, cache_hash.size, 0) --[[@as string]]
185187
uv.fs_close(f)
186188

187-
local offset = 1
189+
local zero = data:find("\0", 1, true)
190+
if not zero then
191+
return
192+
end
193+
194+
if vim.env.VIMRUNTIME ~= data:sub(1, zero - 1) then
195+
return
196+
end
197+
198+
local offset = zero + 1
188199
while offset + 1 < #data do
189200
local header = ffi.cast("uint32_t*", ffi.new("const char[28]", data:sub(offset, offset + 27)))
190201
offset = offset + 28

0 commit comments

Comments
 (0)