fix(lua): corrector.lua now clears specific cand.comment

This commit is contained in:
mirtlecn
2024-04-16 15:12:00 +08:00
committed by mirtlecn
parent dc4f52d4d0
commit 62f3e107a0
8 changed files with 29 additions and 5 deletions

View File

@@ -113,11 +113,14 @@ end
function M.func(input)
for cand in input:iter() do
-- cand.comment 是目前输入的词汇的完整拼音
local c = M.corrections[cand.comment]
if c and cand.text == c.text then
cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment)
elseif cand.type == "user_phrase" or cand.type == "phrase" or cand.type == "sentence" then
cand:get_genuine().comment = ""
local pinyin = cand.comment:match("^(.-)$")
if pinyin and #pinyin > 0 then
local c = M.corrections[pinyin]
if c and cand.text == c.text then
cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment)
else
cand:get_genuine().comment = ""
end
end
yield(cand)
end