From 82bcbbe3326f6f4b0ac799befd36d9f7355dbac1 Mon Sep 17 00:00:00 2001 From: Dvel Date: Mon, 13 Feb 2023 23:52:57 +0800 Subject: [PATCH] improve rime.lua --- rime.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rime.lua b/rime.lua index 8163b53..3450320 100755 --- a/rime.lua +++ b/rime.lua @@ -210,18 +210,20 @@ function reduce_english_filter(input, env) -- filter start local code = env.engine.context.input if env.words[code] then - local l = {} + local first_cand + local index = 0 for cand in input:iter() do - table.insert(l, cand) - if #l >= env.idx then + index = index + 1 + if first_cand then + yield(cand) + else + first_cand = cand + end + if index >= env.idx then + yield(first_cand) break end end - -- 先 yield 汉字,再把英文放到后面 - for i = 2, #l do - yield(l[i]) - end - yield(l[1]) end -- yield other