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
7 changes: 6 additions & 1 deletion lua/gp/dispatcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ local query = function(buf, provider, payload, handler, on_exit, callback)

if qt.provider == "googleai" then
if line:match('"text":') then
content = vim.json.decode("{" .. line .. "}").text
-- Escape raw newlines to prevent json decode from crashing
local sanitized = line:gsub("\r", ""):gsub("\n", "\\n")
local success, decoded = pcall(vim.json.decode, "{" .. sanitized .. "}")
if success and decoded and decoded.text then
content = decoded.text
end
end
end

Expand Down