Skip to content

Commit 089ec63

Browse files
authored
fix: ensure encoding is utf-# (#470)
Fixes #458
1 parent c0d1824 commit 089ec63

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lua/copilot/suggestion/init.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,15 @@ function M.accept(modifier)
614614
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", true, false, true), "n", false)
615615
local bufnr = vim.api.nvim_get_current_buf()
616616

617-
local encoding = vim.api.nvim_get_option_value("fileencoding", { buf = bufnr }) ~= ""
618-
and vim.api.nvim_get_option_value("fileencoding", { buf = bufnr })
619-
or vim.api.nvim_get_option_value("encoding", { scope = "global" })
617+
-- only utf encodings are supported
618+
local encoding = vim.api.nvim_get_option_value("fileencoding", { buf = bufnr })
619+
if not encoding or encoding == "" or encoding ~= "utf-8" or encoding ~= "utf-16" or encoding ~= "utf-32" then
620+
encoding = vim.api.nvim_get_option_value("encoding", { scope = "global" })
621+
622+
if not encoding or encoding == "" or encoding ~= "utf-8" or encoding ~= "utf-16" or encoding ~= "utf-32" then
623+
encoding = "utf-8"
624+
end
625+
end
620626

621627
local lines = vim.split(newText, "\n", { plain = true })
622628
local lines_count = #lines

0 commit comments

Comments
 (0)