From cc7906309963cdfe01f74afab2ec9bd68759fb97 Mon Sep 17 00:00:00 2001 From: Antoine Gaudreau Simard Date: Tue, 18 Mar 2025 17:13:45 -0400 Subject: [PATCH] fix: prevent agent service not initialized fixes #321 --- lua/copilot/client.lua | 2 ++ lua/copilot/suggestion.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index 40e520c4..f16d7ec7 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -12,6 +12,7 @@ local M = { node_version = nil, node_version_error = nil, startup_error = nil, + initialized = false, } ---@param id number @@ -216,6 +217,7 @@ local function prepare_client_config(overrides) vim.notify(string.format("[copilot] setEditorInfo failure: %s", err), vim.log.levels.ERROR) end end) + M.initialized = true end) end, on_exit = function(code, _signal, client_id) diff --git a/lua/copilot/suggestion.lua b/lua/copilot/suggestion.lua index 36378998..0bf1accc 100644 --- a/lua/copilot/suggestion.lua +++ b/lua/copilot/suggestion.lua @@ -402,7 +402,7 @@ local function advance(count, ctx) end local function schedule(ctx) - if not is_enabled() then + if not is_enabled() or not c.initialized then clear() return end