From a90adf65654e5abf96838e2193230f8ed5348c78 Mon Sep 17 00:00:00 2001 From: Syu fu Date: Sun, 15 Dec 2024 18:34:01 +0900 Subject: [PATCH] fix: handle empty fileencoding by falling back to global encoding --- lua/copilot/suggestion.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/copilot/suggestion.lua b/lua/copilot/suggestion.lua index b872d0fa..3c7d9e2d 100644 --- a/lua/copilot/suggestion.lua +++ b/lua/copilot/suggestion.lua @@ -487,7 +487,9 @@ function mod.accept(modifier) 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 encoding = vim.api.nvim_get_option_value('fileencoding', { buf = bufnr }) + 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" }) vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, bufnr, encoding) -- Put cursor at the end of current line. local cursor_keys = ""