Skip to content

Commit

Permalink
feat: topup when empty code
Browse files Browse the repository at this point in the history
e.g.
Input `sgz` and the first candidate is `三个字`. Then continue input `j`, but `sgzj` is empty code. The processor wil topup `三个字` and leave `j` in preedit.
  • Loading branch information
amorphobia committed Aug 30, 2024
1 parent 74f6a2c commit ed11e0f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions schema/lua/jiandao/topup_selector.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
--[[
Topup Selector
Copyright (C) 2020 TsFreddie <https://github.com/TsFreddie>
Copyright (C) 2024 Xuesong Peng <pengxuesong.cn@gmail.com>
https://github.com/xkjd27/rime_jd27c/blob/e38a8c5d010d5a3933e6d6d8265c0cf7b56bfcca/rime/lua/jd27_topup.lua
顶功处理器 by TsFreddie
Expand Down Expand Up @@ -99,6 +100,14 @@ local function processor(key_event, env)
topup(env)
end

if not is_prev_topup and not is_topup and env.mem then
-- input_len < min_len now
local input_to_be = input .. key
if not env.mem:dict_lookup(input_to_be, true, 1) then
context:commit()
end
end

return 2
end

Expand All @@ -113,6 +122,8 @@ local function init(env)
env.auto_clear = config:get_bool("topup/auto_clear") or false
env.topup_command = config:get_bool("topup/topup_command") or false
env.enabled = true

env.mem = env.mem or Memory(env.engine, env.engine.schema)
end

return { init = init, func = processor }

0 comments on commit ed11e0f

Please sign in to comment.