Skip to content

Commit

Permalink
fix: handle empty fileencoding by falling back to global encoding (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syu-fu authored Dec 23, 2024
1 parent d3783b9 commit 886ee73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/copilot/suggestion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ function mod.accept(modifier)
vim.schedule_wrap(function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", 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 = "<End>"
Expand Down

0 comments on commit 886ee73

Please sign in to comment.