diff --git a/lua/avante/suggestion.lua b/lua/avante/suggestion.lua
index fee4782..5b547f8 100644
--- a/lua/avante/suggestion.lua
+++ b/lua/avante/suggestion.lua
@@ -110,6 +110,7 @@ L5: pass
{
role = "assistant",
content = [[
+
[
[
{
@@ -136,6 +137,7 @@ L5: pass
},
]
]
+
]],
},
}
@@ -165,6 +167,7 @@ L5: pass
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
-- Clean up markdown code blocks
full_response = Utils.trim_think_content(full_response)
+ full_response = full_response:gsub("\n(.-)\n", "%1")
full_response = full_response:gsub("^```%w*\n(.-)\n```$", "%1")
full_response = full_response:gsub("(.-)\n```\n?$", "%1")
-- Remove everything before the first '[' to ensure we get just the JSON array
diff --git a/lua/avante/templates/suggesting.avanterules b/lua/avante/templates/suggesting.avanterules
index 27f8790..63903fe 100644
--- a/lua/avante/templates/suggesting.avanterules
+++ b/lua/avante/templates/suggesting.avanterules
@@ -36,6 +36,37 @@ Your task is to suggest code modifications at the cursor position. Follow these
start_row: The starting row of the code snippet you want to replace, start from 1, inclusive
end_row: The ending row of the code snippet you want to replace, start from 1, inclusive
content: The suggested code you want to replace the original code with
+ 3. JSON must be wrapped with tags, for example:
+ {% raw %}
+
+ [
+ [
+ {
+ "start_row": 1,
+ "end_row": 1,
+ "content": "Your suggested code here"
+ },
+ {
+ "start_row": 3,
+ "end_row": 9,
+ "content": "Your suggested code here"
+ }
+ ],
+ [
+ {
+ "start_row": 2,
+ "end_row": 6,
+ "content": "Your suggested code here"
+ },
+ {
+ "start_row": 9,
+ "end_row": 22,
+ "content": "Your suggested code here"
+ }
+ ]
+ ]
+
+ {% endraw %}
Guidelines:
1. Make sure you have maintained the user's existing whitespace and indentation. This is REALLY IMPORTANT!