diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 7f0e4902..ed7f7e28 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -599,6 +599,10 @@ function M.open(config) end config = vim.tbl_deep_extend('force', M.config, config or {}) + if config.headless then + return + end + utils.return_to_normal_mode() state.chat:open(config) state.chat:follow() @@ -676,18 +680,18 @@ end ---@param prompt string? ---@param config CopilotChat.config.shared? function M.ask(prompt, config) - config = vim.tbl_deep_extend('force', M.config, config or {}) - vim.diagnostic.reset(vim.api.nvim_create_namespace('copilot_diagnostics')) + M.open(config) - if not config.headless then - M.open(config) - end + config = vim.tbl_deep_extend('force', state.chat.config, config or {}) + config = vim.tbl_deep_extend('force', M.config, config or {}) prompt = vim.trim(prompt or '') if prompt == '' then return end + vim.diagnostic.reset(vim.api.nvim_create_namespace('copilot_diagnostics')) + if not config.headless then if config.clear_chat_on_new_prompt then M.stop(true)