Skip to content
Open
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
14 changes: 10 additions & 4 deletions lua/codeium/io.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function M.gunzip(path, callback)
vim.o.shell = "powershell"
end
vim.o.shellcmdflag =
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
vim.o.shellredir = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode"
vim.o.shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode"
vim.o.shellquote = ""
Expand Down Expand Up @@ -402,12 +402,18 @@ function M.post(url, params)
local tmpfname = os.tmpname()

if type(params.body) == "table" then
local f = io.open(tmpfname, 'w+')
local ok, json = pcall(vim.fn.json_encode, params.body)
if not ok then
log.error("Failed to encode Codeium payload (invalid UTF-8?)")
return
end

local f = io.open(tmpfname, "w+")
if f == nil then
log.error('Cannot open temporary message file: ' .. tmpfname)
log.error("Cannot open temporary message file: " .. tmpfname)
return
end
f:write(vim.fn.json_encode(params.body))
f:write(json)
f:close()

params.headers = params.headers or {}
Expand Down