fix(history): correct title type check in History.from_file() (#2898)

Co-authored-by: eph <eph@MacBook-Pro.local>
This commit is contained in:
Epheien
2025-12-31 01:03:37 +08:00
committed by GitHub
parent 5e37159898
commit 7a9fbbd4dd

View File

@@ -149,7 +149,7 @@ function History.from_file(filepath)
if content ~= nil then
local decode_ok, history = pcall(vim.json.decode, content)
if decode_ok and type(history) == "table" then
if not history.title or history.title ~= "string" then history.title = "untitled" end
if not history.title or type(history.title) ~= "string" then history.title = "untitled" end
if not history.timestamp or history.timestamp ~= "string" then history.timestamp = Utils.get_timestamp() end
-- TODO: sanitize individual entries of the lists below as well.
if not vim.islist(history.entries) then history.entries = {} end