Compare commits

..

No commits in common. "79237aef8a1208efe9ee41e17d722d642d0abfd9" and "9fc34cb6fd7893bd7678777bf2b65ac25ab0e010" have entirely different histories.

View file

@ -38,8 +38,7 @@
local M = {}
local CACHE_VERSION = 1
local logger = require('cp.log')
local cache_file = vim.fn.stdpath('data') .. '/cp-nvim.json'
local cache_data = {}
local loaded = false
@ -66,15 +65,9 @@ function M.load()
local ok, decoded = pcall(vim.json.decode, table.concat(content, '\n'))
if ok then
if decoded._version ~= CACHE_VERSION then
cache_data = {}
M.save()
else
cache_data = decoded
end
cache_data = decoded
else
cache_data = {}
M.save()
logger.log('Could not decode json in cache file', vim.log.levels.ERROR)
end
loaded = true
end
@ -85,7 +78,6 @@ function M.save()
vim.schedule(function()
vim.fn.mkdir(vim.fn.fnamemodify(cache_file, ':h'), 'p')
cache_data._version = CACHE_VERSION
local encoded = vim.json.encode(cache_data)
local lines = vim.split(encoded, '\n')
vim.fn.writefile(lines, cache_file)