Skip to content

Commit

Permalink
Handle backticks before decoding JSON (yetone#683)
Browse files Browse the repository at this point in the history
* feat: Clean up full_response before JSON decoding

* fix: make backtick matching more accurate
  • Loading branch information
ryul99 authored Oct 8, 2024
1 parent 2a72dfa commit 08bed9e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lua/avante/suggestion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function Suggestion:suggest()
vim.schedule(function()
local cursor_row, cursor_col = Utils.get_cursor_pos()
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
full_response = full_response:gsub("^```%w*\n(.-)\n```$", "%1")
local ok, suggestions = pcall(vim.json.decode, full_response)
if not ok then
Utils.error("Error while decoding suggestions: " .. full_response, { once = true, title = "Avante" })
Expand Down

0 comments on commit 08bed9e

Please sign in to comment.