From 75ebef9fbe51ce07977f8521cccda89baca53715 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 21 Jul 2025 11:50:14 +0800 Subject: [PATCH] fix: tool_info is nil --- lua/avante/history/init.lua | 1 + lua/avante/llm_tools/edit_file.lua | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lua/avante/history/init.lua b/lua/avante/history/init.lua index b88ba53..524e10b 100644 --- a/lua/avante/history/init.lua +++ b/lua/avante/history/init.lua @@ -241,6 +241,7 @@ local function refresh_history(messages, tools, files, add_diagnostic, tools_to_ if use then -- This is a tool invocation message. We will be handling both use and result together. local tool_info = tools[use.id] + if not tool_info then goto continue end if not tool_info.result then goto continue end if tool_count < tools_to_text then diff --git a/lua/avante/llm_tools/edit_file.lua b/lua/avante/llm_tools/edit_file.lua index 826835d..b66077e 100644 --- a/lua/avante/llm_tools/edit_file.lua +++ b/lua/avante/llm_tools/edit_file.lua @@ -59,6 +59,8 @@ M.func = vim.schedule_wrap(function(input, opts) 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 input.target_file then return false, "target_file not provided" end + local ok, lines = pcall(Utils.read_file_from_buf_or_disk, input.target_file) if not ok then local f = io.open(input.target_file, "r")