From 6f28f3dbb83b467f57a55146d1a11a9c088bfa7c Mon Sep 17 00:00:00 2001 From: HC <32760059+abcdefg233@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:32:11 +0800 Subject: [PATCH] fix: is_in_user_dict (#741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持 table_translator 造出的用户词。 --- lua/is_in_user_dict.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lua/is_in_user_dict.lua b/lua/is_in_user_dict.lua index deecfd7..11d1aba 100644 --- a/lua/is_in_user_dict.lua +++ b/lua/is_in_user_dict.lua @@ -7,19 +7,18 @@ local M = {} function M.init(env) local config = env.engine.schema.config env.name_space = env.name_space:gsub('^*', '') - M.is_in_user_dict = config:get_bool(env.name_space) + M.is_in_user_dict = config:get_bool(env.name_space) or nil end -function M.func(input, env) +local is_user = { + user_table = true, + user_phrase = true, +} + +function M.func(input) for cand in input:iter() do - if M.is_in_user_dict then - if cand.type == "user_phrase" then - cand.comment = cand.comment .. '*' - end - else - if cand.type ~= "user_phrase" then - cand.comment = cand.comment .. '*' - end + if is_user[cand.type] == M.is_in_user_dict then + cand.comment = cand.comment .. '*' end yield(cand) end