Skip to content

Commit

Permalink
fix: 修复「辅码 lua」上屏问题
Browse files Browse the repository at this point in the history
- 修复「小鹤双拼辅码」可能存在的问题

resolved: #57
  • Loading branch information
Mintimate committed Mar 30, 2024
1 parent 4375746 commit 8b487ed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lua/auxCode_filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function AuxFilter.init(env)
-- 設定預設觸發鍵為分號,並從配置中讀取自訂的觸發鍵
env.trigger_key = config:get_string("axu_code/trigger_word") or ";"
-- 对内容进行替换
env.trigger_key = alt_lua_punc( env.trigger_key )
env.trigger_key_string = alt_lua_punc( env.trigger_key )

-- 设定是否显示辅助码,默认为显示
env.show_aux_notice = config:get_string("axu_code/show_aux_notice") or 'always'
Expand All @@ -35,13 +35,13 @@ function AuxFilter.init(env)
----------------------------
env.notifier = engine.context.select_notifier:connect(function(ctx)
-- 含有輔助碼分隔符才處理
if not string.find(ctx.input, env.trigger_key) then
if not string.find(ctx.input, env.trigger_key_string) then
return
end

local preedit = ctx:get_preedit()
local removeAuxInput = ctx.input:match("([^,]+)" .. env.trigger_key)
local reeditTextFront = preedit.text:match("([^,]+)" .. env.trigger_key)
local removeAuxInput = ctx.input:match("([^,]+)" .. env.trigger_key_string)
local reeditTextFront = preedit.text:match("([^,]+)" .. env.trigger_key_string)

-- ctx.text 隨著選字的進行,oaoaoa; 有如下的輸出:
-- ---- 有輔助碼 ----
Expand Down Expand Up @@ -199,9 +199,9 @@ function AuxFilter.func(input, env)

-- 分割部分正式開始
local auxStr = ''
if string.find(inputCode, env.trigger_key) then
if string.find(inputCode, env.trigger_key_string) then
-- 字符串中包含輔助碼分隔符
local trigger_pattern = env.trigger_key:gsub("%W", "%%%1") -- 處理特殊字符
local trigger_pattern = env.trigger_key_string:gsub("%W", "%%%1") -- 處理特殊字符
local localSplit = inputCode:match(trigger_pattern .. "([^,]+)")
if localSplit then
auxStr = string.sub(localSplit, 1, 2)
Expand Down Expand Up @@ -234,7 +234,7 @@ function AuxFilter.func(input, env)
cand = ShadowCandidate(originalCand, originalCand.type, shadowText,
originalCand.comment .. shadowComment .. '(' .. codeComment .. ')')
elseif env.show_aux_notice == "trigger" then
if string.find(inputCode,env.trigger_key) then
if string.find(inputCode,env.trigger_key_string) then
cand.comment = '(' .. codeComment .. ')'
end
else
Expand Down

0 comments on commit 8b487ed

Please sign in to comment.