From 272c70694d99eab621f4e0b4d7a8c239ebdd7f5e Mon Sep 17 00:00:00 2001 From: Dvel Date: Sat, 8 Apr 2023 14:45:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20lua=20=E9=99=8D=E4=BD=8E=E8=8B=B1?= =?UTF-8?q?=E8=AF=AD=E5=8D=95=E8=AF=8D=E9=A1=BA=E5=BA=8F=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20#147?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rime.lua | 14 ++++++++------ rime_ice.schema.yaml | 6 +++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/rime.lua b/rime.lua index 12456ad..e81e723 100644 --- a/rime.lua +++ b/rime.lua @@ -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 diff --git a/rime_ice.schema.yaml b/rime_ice.schema.yaml index f640755..7742313 100644 --- a/rime_ice.schema.yaml +++ b/rime_ice.schema.yaml @@ -98,7 +98,11 @@ reduce_english_filter: # 降低到第 idx 个位置 idx: 2 # 要降低的单词,匹配的是输入码,即全小写。 - words: [rug, bus, ship, laos, bail, bam, bans, bib, bos, chic, chit, dab, dag, dal, dit, dub, dug, fab, gam, ger, gus, hem, hep, hud, kat, lam, lax, lex, lug, lux, moc, mos, mot, mum, nad, nay, nib, nip, pak, pap, pax, rig, rum, sac, sal, sax, sec, shin, sis, ska, slang, sus, tad, taj, tac, tic, yep, yum] + words: [rug, bus, ship, laos, bail, bam, bans, bib, bos, chic, chit, dab, dag, + dal, dit, dub, dug, fab, gam, ger, gus, hem, hep, hud, kat, lam, lax, lex, lug, + lux, moc, mos, mot, mum, nad, nay, nib, nip, pak, pap, pax, rig, rum, sac, sal, + sax, sec, shin, sis, ska, slang, sus, tad, taj, tac, tic, yep, yum, fax, cain, + key, mob, buy] # 从 default 继承快捷键