fix: use path instead of target_file in the edit_file input (#2526)
This commit is contained in:
@@ -19,8 +19,8 @@ M.param = {
|
|||||||
type = "table",
|
type = "table",
|
||||||
fields = {
|
fields = {
|
||||||
{
|
{
|
||||||
name = "target_file",
|
name = "path",
|
||||||
description = "The target file to modify.",
|
description = "The target file path to modify.",
|
||||||
type = "string",
|
type = "string",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ M.returns = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type AvanteLLMToolFunc<{ target_file: string, instructions: string, code_edit: string }>
|
---@type AvanteLLMToolFunc<{ path: string, instructions: string, code_edit: string }>
|
||||||
M.func = vim.schedule_wrap(function(input, opts)
|
M.func = vim.schedule_wrap(function(input, opts)
|
||||||
local on_complete = opts.on_complete
|
local on_complete = opts.on_complete
|
||||||
if not on_complete then return false, "on_complete not provided" end
|
if not on_complete then return false, "on_complete not provided" end
|
||||||
@@ -59,11 +59,11 @@ M.func = vim.schedule_wrap(function(input, opts)
|
|||||||
if not provider then return false, "morph provider not found" end
|
if not provider then return false, "morph provider not found" end
|
||||||
if not provider.is_env_set() then return false, "morph provider not set" end
|
if not provider.is_env_set() then return false, "morph provider not set" end
|
||||||
|
|
||||||
if not input.target_file then return false, "target_file not provided" end
|
if not input.path then return false, "path not provided" end
|
||||||
|
|
||||||
local ok, lines = pcall(Utils.read_file_from_buf_or_disk, input.target_file)
|
local ok, lines = pcall(Utils.read_file_from_buf_or_disk, input.path)
|
||||||
if not ok then
|
if not ok then
|
||||||
local f = io.open(input.target_file, "r")
|
local f = io.open(input.path, "r")
|
||||||
if f then
|
if f then
|
||||||
local original_code = f:read("*all")
|
local original_code = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
@@ -165,7 +165,7 @@ M.func = vim.schedule_wrap(function(input, opts)
|
|||||||
|
|
||||||
local str_replace = require("avante.llm_tools.str_replace")
|
local str_replace = require("avante.llm_tools.str_replace")
|
||||||
local new_input = {
|
local new_input = {
|
||||||
path = input.target_file,
|
path = input.path,
|
||||||
old_str = original_code,
|
old_str = original_code,
|
||||||
new_str = jsn.choices[1].message.content,
|
new_str = jsn.choices[1].message.content,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user