From e46fa23fe7c43a29c849fb9b6a1d565d2e0b83f1 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 18 Feb 2024 14:07:35 +0800 Subject: [PATCH] fix(code_actions): Add check for 'No diagnostics available' in diagnostic prompts --- lua/CopilotChat/code_actions.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/CopilotChat/code_actions.lua b/lua/CopilotChat/code_actions.lua index 561477f..78685cd 100644 --- a/lua/CopilotChat/code_actions.lua +++ b/lua/CopilotChat/code_actions.lua @@ -11,6 +11,10 @@ local user_prompt_actions = {} local function generate_fix_diagnostic_prompt() local diagnostic = utils.get_diagnostics() + if diagnostic == 'No diagnostics available' then + return diagnostic + end + local file_name = vim.fn.expand('%:t') local line_number = vim.fn.line('.') return 'Please assist with fixing the following diagnostic issue in file: "' @@ -23,6 +27,10 @@ end local function generate_explain_diagnostic_prompt() local diagnostic = utils.get_diagnostics() + if diagnostic == 'No diagnostics available' then + return diagnostic + end + local file_name = vim.fn.expand('%:t') local line_number = vim.fn.line('.') return 'Please explain the following diagnostic issue in file: "'