fix: remove trailing spaces each line when editing files (#2612)

This commit is contained in:
brook hong
2025-08-16 14:16:38 +08:00
committed by GitHub
parent be0937a459
commit c1ccb7867a
4 changed files with 21 additions and 1 deletions

View File

@@ -56,6 +56,11 @@ M.returns = {
---@type AvanteLLMToolFunc<{ path: string, old_str: string, new_str: string }>
function M.func(input, opts)
local replace_in_file = require("avante.llm_tools.replace_in_file")
local Utils = require("avante.utils")
-- Remove trailing spaces from the new string
input.new_str = Utils.remove_trailing_spaces(input.new_str)
local diff = "------- SEARCH\n" .. input.old_str .. "\n=======\n" .. input.new_str
if not opts.streaming then diff = diff .. "\n+++++++ REPLACE" end
local new_input = {