fix: do not use str_replace_editor (#2428)

This commit is contained in:
yetone
2025-07-10 10:17:48 +08:00
committed by GitHub
parent 6a9424a63b
commit 14cfccdba9
2 changed files with 14 additions and 40 deletions

View File

@@ -575,6 +575,7 @@ function M.func(opts, on_log, on_complete, session_ctx)
end
local function highlight_diff_blocks()
local line_count = vim.api.nvim_buf_line_count(bufnr)
vim.api.nvim_buf_clear_namespace(bufnr, NAMESPACE, 0, -1)
local base_line_ = 0
local max_col = vim.o.columns
@@ -591,17 +592,19 @@ function M.func(opts, on_log, on_complete, session_ctx)
:totable()
-- local extmark_line = math.max(0, start_line - 2)
local end_row = start_line + #diff_block.new_lines - 1
local delete_extmark_id = vim.api.nvim_buf_set_extmark(bufnr, NAMESPACE, end_row - 1, 0, {
virt_lines = deleted_virt_lines,
hl_eol = true,
hl_mode = "combine",
})
local incoming_extmark_id = vim.api.nvim_buf_set_extmark(bufnr, NAMESPACE, start_line - 1, 0, {
hl_group = Highlights.INCOMING,
hl_eol = true,
hl_mode = "combine",
end_row = end_row,
})
local delete_extmark_id =
vim.api.nvim_buf_set_extmark(bufnr, NAMESPACE, math.min(math.max(end_row - 1, 0), line_count - 1), 0, {
virt_lines = deleted_virt_lines,
hl_eol = true,
hl_mode = "combine",
})
local incoming_extmark_id =
vim.api.nvim_buf_set_extmark(bufnr, NAMESPACE, math.min(math.max(start_line - 1, 0), line_count - 1), 0, {
hl_group = Highlights.INCOMING,
hl_eol = true,
hl_mode = "combine",
end_row = end_row,
})
diff_block.delete_extmark_id = delete_extmark_id
diff_block.incoming_extmark_id = incoming_extmark_id
end

View File

@@ -1,7 +1,6 @@
local Utils = require("avante.utils")
local Clipboard = require("avante.clipboard")
local P = require("avante.providers")
local Config = require("avante.config")
local HistoryMessage = require("avante.history_message")
local JsonParser = require("avante.libs.jsonparser")
@@ -363,35 +362,7 @@ function M:parse_curl_args(prompt_opts)
local tools = {}
if not disable_tools and prompt_opts.tools then
for _, tool in ipairs(prompt_opts.tools) do
if Config.mode == "agentic" then
if tool.name == "create_file" then goto continue end
if tool.name == "view" then goto continue end
if tool.name == "str_replace" then goto continue end
if tool.name == "create" then goto continue end
if tool.name == "insert" then goto continue end
if tool.name == "undo_edit" then goto continue end
end
table.insert(tools, self:transform_tool(tool))
::continue::
end
end
if prompt_opts.tools and #prompt_opts.tools > 0 and Config.mode == "agentic" then
if provider_conf.model:match("claude%-sonnet%-4") then
table.insert(tools, {
type = "text_editor_20250429",
name = "str_replace_based_edit_tool",
})
elseif provider_conf.model:match("claude%-3%-7%-sonnet") then
table.insert(tools, {
type = "text_editor_20250124",
name = "str_replace_editor",
})
elseif provider_conf.model:match("claude%-3%-5%-sonnet") then
table.insert(tools, {
type = "text_editor_20250124",
name = "str_replace_editor",
})
end
end