fix: validate oldText and newText before render diff (#2681)

This commit is contained in:
yetone
2025-09-03 14:01:22 +08:00
committed by GitHub
parent faff4c4226
commit 181befe20b

View File

@@ -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)