From 25be6663771807e0169b4e8ace4b9b0ab7b743a0 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 19 Jun 2025 17:26:19 +0800 Subject: [PATCH] fix: respect the minimize_diff configuration (#2267) --- lua/avante/llm_tools/replace_in_file.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lua/avante/llm_tools/replace_in_file.lua b/lua/avante/llm_tools/replace_in_file.lua index 924938e..4f9933b 100644 --- a/lua/avante/llm_tools/replace_in_file.lua +++ b/lua/avante/llm_tools/replace_in_file.lua @@ -263,12 +263,17 @@ function M.func(opts, on_log, on_complete, session_ctx) end local old_string = table.concat(old_lines, "\n") local new_string = table.concat(new_lines, "\n") - ---@diagnostic disable-next-line: assign-type-mismatch, missing-fields - local patch = vim.diff(old_string, new_string, { ---@type integer[][] - algorithm = "histogram", - result_type = "indices", - ctxlen = vim.o.scrolloff, - }) + local patch + if Config.behaviour.minimize_diff then + ---@diagnostic disable-next-line: assign-type-mismatch, missing-fields + patch = vim.diff(old_string, new_string, { ---@type integer[][] + algorithm = "histogram", + result_type = "indices", + ctxlen = vim.o.scrolloff, + }) + else + patch = { { 1, #old_lines, 1, #new_lines } } + end local diff_blocks_ = {} for _, hunk in ipairs(patch) do local start_a, count_a, start_b, count_b = unpack(hunk)