Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unable to Determine Encoding for New Files #351

Closed
lljbash opened this issue Dec 20, 2024 · 5 comments
Closed

Error: Unable to Determine Encoding for New Files #351

lljbash opened this issue Dec 20, 2024 · 5 comments

Comments

@lljbash
Copy link

lljbash commented Dec 20, 2024

After #336 was merged, creating a new file in Neovim and attempting to complete with Copilot triggers the following error, disrupting the completion process:

Error executing vim.schedule lua callback: ...oad/nvim-linux64/share/nvim/runtime/lua/vim/lsp/util.lua:178: Invalid encoding: ""
stack traceback:
	[C]: in function 'error'
	...oad/nvim-linux64/share/nvim/runtime/lua/vim/lsp/util.lua:178: in function 'get_line_byte_from_position'
	...oad/nvim-linux64/share/nvim/runtime/lua/vim/lsp/util.lua:485: in function 'apply_text_edits'
	...l/share/nvim/lazy/copilot.lua/lua/copilot/suggestion.lua:491: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

set encoding? shows encoding=utf-8. Closing and reopening the file resolves the issue.

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068

@powerLEO101
Copy link

I am meeting the same issue, but closing and reopening the file does not resolves for me.

@mars90226
Copy link

mars90226 commented Dec 21, 2024

I add the following code to use 'encoding' as default encoding to fix this:

	if encoding == "" then
		encoding = vim.api.nvim_get_option_value('encoding', {})
	end

Put these below the line 490 of suggession.lua file to fix the problem.

I don't know if this is the best fix, though.

@Syu-fu
Copy link
Contributor

Syu-fu commented Dec 21, 2024

This problem is already fixed in #346

@lljbash
Copy link
Author

lljbash commented Dec 23, 2024

This problem is already fixed in #346

Oh, thanks for the fix! I hope this gets merged as soon as possible.

@zbirenbaum
Copy link
Owner

Fixed via #346, thanks @Syu-fu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants