fix(replace_in_file): added a replace substring logic (#2438)

This commit is contained in:
Raul Luzetti
2025-07-13 23:14:16 -03:00
committed by GitHub
parent a78af4ce99
commit e06f55d353

View File

@@ -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