diff --git a/lua/copilot/suggestion.lua b/lua/copilot/suggestion.lua index bac5e925..b872d0fa 100644 --- a/lua/copilot/suggestion.lua +++ b/lua/copilot/suggestion.lua @@ -486,7 +486,9 @@ 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) - vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, vim.api.nvim_get_current_buf(), "utf-16") + local bufnr = vim.api.nvim_get_current_buf() + local encoding = vim.api.nvim_get_option_value('fileencoding', { buf = bufnr }) + vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, bufnr, encoding) -- Put cursor at the end of current line. local cursor_keys = "" if has_nvim_0_10_x then