Skip to content

Commit

Permalink
feat(lua): 反查不再過濾字集
Browse files Browse the repository at this point in the history
  • Loading branch information
ksqsf committed Dec 20, 2024
1 parent 3b0a93e commit 7554148
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lua/moran_charset_filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
function Top.func(t_input, env)
local extended = env.engine.context:get_option("extended_charset")

if extended or env.charset == nil then
if extended or env.charset == nil or Top.IsReverseLookup(env) then
for cand in t_input:iter() do
yield(cand)
end
Expand Down Expand Up @@ -50,4 +50,24 @@ function Top.CodepointInCharset(env, codepoint)
return res
end

function Top.IsReverseLookup(env)
local seg = env.engine.context.composition:back()
if not seg then
return false
end
return seg:has_tag("reverse_tiger")
or seg:has_tag("reverse_zrlf")
or seg:has_tag("reverse_cangjie5")
or seg:has_tag("reverse_stroke")
or seg:has_tag("reverse_tick")

-- 所有反查都不過濾:
-- for tag, _ in pairs(seg.tags) do
-- if tag:match("^reverse_") then
-- return true
-- end
-- end
-- return false
end

return Top

0 comments on commit 7554148

Please sign in to comment.