Skip to content

Commit

Permalink
check if state file exists before trying to open it
Browse files Browse the repository at this point in the history
Fixes an issue with an warning popping up on new installations if the state file does not exist.
  • Loading branch information
marcomayer authored and Robitx committed Feb 3, 2024
1 parent 816cd34 commit d660d9b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,10 @@ end
M.refresh_state = function()
local state_file = M.config.state_dir .. "/state.json"

local state = M.file_to_table(state_file) or {}
local state = {}
if vim.fn.filereadable(state_file) ~= 0 then
state = M.file_to_table(state_file) or {}
end

M._state.chat_agent = M._state.chat_agent or state.chat_agent or nil
if M._state.chat_agent == nil or not M.agents[M._state.chat_agent] then
Expand Down

0 comments on commit d660d9b

Please sign in to comment.