Skip to content

Commit d660d9b

Browse files
marcomayerRobitx
authored andcommitted
check if state file exists before trying to open it
Fixes an issue with an warning popping up on new installations if the state file does not exist.
1 parent 816cd34 commit d660d9b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/gp/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,10 @@ end
887887
M.refresh_state = function()
888888
local state_file = M.config.state_dir .. "/state.json"
889889

890-
local state = M.file_to_table(state_file) or {}
890+
local state = {}
891+
if vim.fn.filereadable(state_file) ~= 0 then
892+
state = M.file_to_table(state_file) or {}
893+
end
891894

892895
M._state.chat_agent = M._state.chat_agent or state.chat_agent or nil
893896
if M._state.chat_agent == nil or not M.agents[M._state.chat_agent] then

0 commit comments

Comments
 (0)