From 08bed9e256900ce01564f6b8280d1f2c9c5ce273 Mon Sep 17 00:00:00 2001 From: Changmin Choi Date: Tue, 8 Oct 2024 17:13:56 +0900 Subject: [PATCH] Handle backticks before decoding JSON (#683) * feat: Clean up full_response before JSON decoding * fix: make backtick matching more accurate --- lua/avante/suggestion.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/avante/suggestion.lua b/lua/avante/suggestion.lua index e3414e7..baeaeab 100644 --- a/lua/avante/suggestion.lua +++ b/lua/avante/suggestion.lua @@ -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" })