fix lua 降低英语单词顺序的逻辑 #147

This commit is contained in:
Dvel
2023-04-08 14:45:10 +08:00
parent 32cbf184af
commit 272c70694d
2 changed files with 13 additions and 7 deletions

View File

@@ -199,17 +199,19 @@ function reduce_english_filter(input, env)
-- filter start
local code = env.engine.context.input
if env.words[code] then
local first_cand
local pending_cands = {}
local index = 0
for cand in input:iter() do
index = index + 1
if first_cand then
yield(cand)
if string.lower(cand.text) == code then
table.insert(pending_cands, cand)
else
first_cand = cand
yield(cand)
end
if index >= env.idx then
yield(first_cand)
if index >= env.idx + #pending_cands - 1 then
for _, cand in ipairs(pending_cands) do
yield(cand)
end
break
end
end