From 181befe20bed11452e16d69ce057ca5db26e2dc6 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 3 Sep 2025 14:01:22 +0800 Subject: [PATCH] fix: validate oldText and newText before render diff (#2681) --- lua/avante/history/render.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/avante/history/render.lua b/lua/avante/history/render.lua index ff7f165..c9a97d4 100644 --- a/lua/avante/history/render.lua +++ b/lua/avante/history/render.lua @@ -289,7 +289,13 @@ function M.get_content_lines(content, decoration, truncate) table.insert(lines, line) end end - elseif content_item.type == "diff" then + elseif + content_item.type == "diff" + and content_item.oldText ~= nil + and content_item.newText ~= nil + and content_item.oldText ~= vim.NIL + and content_item.newText ~= vim.NIL + then local relative_path = Utils.relative_path(content_item.path) table.insert(lines, Line:new({ { decoration }, { "Path: " .. relative_path } })) local lines_ = M.get_diff_lines(content_item.oldText, content_item.newText, decoration, truncate)