fix(copilot): fail to decode the empty token file (#1414)

This commit is contained in:
Xiaochao Dong
2025-02-27 11:44:24 +08:00
committed by GitHub
parent 9c9fadd256
commit 81067b31aa

View File

@@ -284,7 +284,10 @@ function M.setup_file_watcher()
{},
vim.schedule_wrap(function()
-- Reload token from file
if copilot_token_file:exists() then M.state.github_token = vim.json.decode(copilot_token_file:read()) end
if copilot_token_file:exists() then
local ok, token = pcall(vim.json.decode, copilot_token_file:read())
if ok then M.state.github_token = token end
end
end)
)
end