Skip to content

Commit ddeba5b

Browse files
committed
fix: wrong buffer encoding breaks accepting suggestions zbirenbaum#336
1 parent f8d8d87 commit ddeba5b

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
@@ -486,7 +486,9 @@ function mod.accept(modifier)
486486
-- Hack for 'autoindent', makes the indent persist. Check `:help 'autoindent'`.
487487
vim.schedule_wrap(function()
488488
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", true, false, true), "n", false)
489-
vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, vim.api.nvim_get_current_buf(), "utf-16")
489+
local bufnr = vim.api.nvim_get_current_buf()
490+
local encoding = vim.api.nvim_get_option_value('fileencoding', { buf = bufnr })
491+
vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, bufnr, encoding)
490492
-- Put cursor at the end of current line.
491493
local cursor_keys = "<End>"
492494
if has_nvim_0_10_x then

0 commit comments

Comments
 (0)