Skip to content

Commit 886ee73

Browse files
authored
fix: handle empty fileencoding by falling back to global encoding (#346)
1 parent d3783b9 commit 886ee73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lua/copilot/suggestion.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ function mod.accept(modifier)
487487
vim.schedule_wrap(function()
488488
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", true, false, true), "n", false)
489489
local bufnr = vim.api.nvim_get_current_buf()
490-
local encoding = vim.api.nvim_get_option_value('fileencoding', { buf = bufnr })
490+
local encoding = vim.api.nvim_get_option_value("fileencoding", { buf = bufnr }) ~= ""
491+
and vim.api.nvim_get_option_value("fileencoding", { buf = bufnr })
492+
or vim.api.nvim_get_option_value("encoding", { scope = "global" })
491493
vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, bufnr, encoding)
492494
-- Put cursor at the end of current line.
493495
local cursor_keys = "<End>"

0 commit comments

Comments
 (0)