refactor: history messages (#1934)

This commit is contained in:
yetone
2025-04-30 03:07:18 +08:00
committed by GitHub
parent f9aa75459d
commit f10b8383e3
36 changed files with 1699 additions and 1462 deletions

View File

@@ -77,10 +77,24 @@ function StreamingJSONParser:parse(chunk)
-- Handle strings specially (they can contain JSON control characters)
if self.state.inString then
if self.state.escaping then
self.state.stringBuffer = self.state.stringBuffer .. char
local escapeMap = {
['"'] = '"',
["\\"] = "\\",
["/"] = "/",
["b"] = "\b",
["f"] = "\f",
["n"] = "\n",
["r"] = "\r",
["t"] = "\t",
}
local escapedChar = escapeMap[char]
if escapedChar then
self.state.stringBuffer = self.state.stringBuffer .. escapedChar
else
self.state.stringBuffer = self.state.stringBuffer .. char
end
self.state.escaping = false
elseif char == "\\" then
self.state.stringBuffer = self.state.stringBuffer .. char
self.state.escaping = true
elseif char == '"' then
-- End of string