Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" })
Comment on lines +490 to +492

@unlimitedsola unlimitedsola Dec 19, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find this easier to read.

Suggested change
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" })
local encoding = vim.api.nvim_get_option_value("fileencoding", { buf = bufnr })
if encoding == "" then
encoding = vim.api.nvim_get_option_value("fileencoding", { scope = "global" })
end

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