diff --git a/lua/copilot/suggestion.lua b/lua/copilot/suggestion.lua index 3c7d9e2d..063a07c4 100644 --- a/lua/copilot/suggestion.lua +++ b/lua/copilot/suggestion.lua @@ -215,6 +215,11 @@ local function get_current_suggestion(ctx) return nil end + if choice.text == "" then + -- If the only content is , there's no suggestion + return nil + end + return choice end) @@ -486,10 +491,10 @@ function mod.accept(modifier) -- Hack for 'autoindent', makes the indent persist. Check `:help 'autoindent'`. vim.schedule_wrap(function() vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", false) - local bufnr = vim.api.nvim_get_current_buf() + local bufnr = vim.api.nvim_get_current_buf() local encoding = vim.api.nvim_get_option_value("fileencoding", { buf = bufnr }) ~= "" and vim.api.nvim_get_option_value("fileencoding", { buf = bufnr }) - or vim.api.nvim_get_option_value("encoding", { scope = "global" }) + or vim.api.nvim_get_option_value("encoding", { scope = "global" }) vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, bufnr, encoding) -- Put cursor at the end of current line. local cursor_keys = ""