@@ -87,8 +87,8 @@ function AuxFilter.readAuxTxt(txtpath)
8787
8888 local auxCodes = {}
8989 for line in file :lines () do
90- line = line :match (" [^\r\n ]+" ) -- 去掉換行符,不然 value 是帶著 \n 的
91- local key , value = line :match (" ([^=]+)=(.+)" ) -- 分割 = 左右的變數
90+ local clean_line = line :match (" [^\r\n ]+" ) -- 去掉換行符,不然 value 是帶著 \n 的
91+ local key , value = clean_line :match (" ([^=]+)=(.+)" ) -- 分割 = 左右的變數
9292 if key and value then
9393 if auxCodes [key ] then
9494 auxCodes [key ] = auxCodes [key ] .. " " .. value
@@ -213,8 +213,9 @@ function AuxFilter.func(input, env)
213213
214214 -- 遍歷每一個待選項
215215 for cand in input :iter () do
216- local auxCodes = AuxFilter .aux_code [cand .text ] -- 仅单字非 nil
217- local fullAuxCodes = AuxFilter .fullAux (env , cand .text )
216+ local current_cand = cand
217+ local auxCodes = AuxFilter .aux_code [current_cand .text ] -- 仅单字非 nil
218+ local fullAuxCodes = AuxFilter .fullAux (env , current_cand .text )
218219
219220 -- 给候选项添加辅助代码提示
220221 if env .show_aux_notice and auxCodes and # auxCodes > 0 then
@@ -230,29 +231,29 @@ function AuxFilter.func(input, env)
230231
231232 if showComment then
232233 -- 处理 simplifier
233- if cand :get_dynamic_type () == " Shadow" then
234- local shadowText = cand .text
235- local shadowComment = cand .comment
236- local originalCand = cand :get_genuine ()
237- cand = ShadowCandidate (originalCand , originalCand .type , shadowText ,
234+ if current_cand :get_dynamic_type () == " Shadow" then
235+ local shadowText = current_cand .text
236+ local shadowComment = current_cand .comment
237+ local originalCand = current_cand :get_genuine ()
238+ current_cand = ShadowCandidate (originalCand , originalCand .type , shadowText ,
238239 originalCand .comment .. shadowComment .. ' (' .. codeComment .. ' )' )
239240 else
240- cand .comment = cand .comment .. ' (' .. codeComment .. ' )'
241+ current_cand .comment = current_cand .comment .. ' (' .. codeComment .. ' )'
241242 end
242243 end
243244 end
244245
245246 -- 過濾輔助碼
246247 if # auxStr == 0 then
247248 -- 沒有輔助碼、不需篩選,直接返回待選項
248- yield (cand )
249- elseif # auxStr > 0 and fullAuxCodes and (cand .type == ' user_phrase' or cand .type == ' phrase' or cand .type == ' simplified' ) and
249+ yield (current_cand )
250+ elseif # auxStr > 0 and fullAuxCodes and (current_cand .type == ' user_phrase' or current_cand .type == ' phrase' or current_cand .type == ' simplified' ) and
250251 AuxFilter .match (fullAuxCodes , auxStr ) then
251252 -- 匹配到辅助码的待选项,直接插入到候选框中( 获得靠前的位置 )
252- yield (cand )
253+ yield (current_cand )
253254 else
254255 -- 待选项字词 没有 匹配到当前的辅助码,插入到列表中,最后插入到候选框里( 获得靠后的位置 )
255- -- table.insert(insertLater, cand )
256+ -- table.insert(insertLater, current_cand )
256257 -- 更新逻辑:没有匹配上就不出现再候选框里,提升性能
257258 end
258259 end
0 commit comments