From e06f55d353a169adb7945c5e813d339b6377f912 Mon Sep 17 00:00:00 2001 From: Raul Luzetti Date: Sun, 13 Jul 2025 23:14:16 -0300 Subject: [PATCH] fix(replace_in_file): added a replace substring logic (#2438) --- lua/avante/llm_tools/replace_in_file.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/avante/llm_tools/replace_in_file.lua b/lua/avante/llm_tools/replace_in_file.lua index f8b7f16..cf82c7f 100644 --- a/lua/avante/llm_tools/replace_in_file.lua +++ b/lua/avante/llm_tools/replace_in_file.lua @@ -102,6 +102,10 @@ M.returns = { ---@param diff string ---@return string local function fix_diff(diff) + -- Normalize block headers to the expected ones (fix for some LLMs output) + diff = diff:gsub("<<<<<<<%s*SEARCH", "------- SEARCH") + diff = diff:gsub(">>>>>>>%s*REPLACE", "+++++++ REPLACE") + local has_search_line = diff:match("^%s*-------* SEARCH") ~= nil if has_search_line then return diff end