Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/forFudan/yuhao into main
Browse files Browse the repository at this point in the history
  • Loading branch information
forFudan committed Jun 12, 2023
2 parents 44a4686 + 749c8a9 commit d21d23e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions beta/schema/lua/yuhao/yuhao_embeded_cands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ local separator = ""

-- 讀取 schema.yaml 開關設置:
local option_name = "embeded_cands"
local embeded_cands = nil

function embeded_cands_filter.init(env)
-- 初始化局部表變量, 並裝入env
local embeded = {}
env.embeded = embeded
local handler = function(ctx, name)
-- 通知回調, 當改變選項值時更新暫存的值
if name == option_name then
embeded_cands = ctx:get_option(name)
if embeded_cands == nil then
embeded.embeded_cands = ctx:get_option(name)
if embeded.embeded_cands == nil then
-- 當選項不存在時默認爲啓用狀態
embeded_cands = true
embeded.embeded_cands = true
end
end
end
Expand Down Expand Up @@ -88,7 +90,7 @@ end

-- 過濾器
function embeded_cands_filter.func(input, env)
if not embeded_cands then
if not env.embeded.embeded_cands then
for cand in input:iter() do
yield(cand)
end
Expand Down

0 comments on commit d21d23e

Please sign in to comment.