From 5f30dfbd72a40844016fa4f525a039b724a11d58 Mon Sep 17 00:00:00 2001 From: mirtlecn Date: Tue, 20 Aug 2024 14:03:41 +0800 Subject: [PATCH] chore(lua): fetch upstream search.lua --- lua/search.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/search.lua b/lua/search.lua index 68033ca..6345a95 100755 --- a/lua/search.lua +++ b/lua/search.lua @@ -32,6 +32,7 @@ local function update_dict_entry( s, code, mem, proj ) return 0 end local e = DictEntry() + s = s:gsub( '^%s+', '' ):gsub( '%s+$', '' ) e.text = s local pos = {} @@ -80,7 +81,7 @@ end -- 通过 reverse db 查询(以字查码,然后比对辅码是否相同,快,但只能匹配未经算法转换的码) local function reverse_lookup( code_projection, db_table, wildcard, text, s, global_match ) - if wildcard then s = s:gsub( wildcard, '.*' ) end + if wildcard then s = s:gsub( wildcard, '.+' ) end if code_projection then -- old librime do not return original string when apply failed local p = code_projection:apply( s, true ) @@ -294,6 +295,8 @@ function f.fini( env ) if env.if_reverse_lookup or env.if_schema_lookup then env.notifier:disconnect() env.commit_notifier:disconnect() + if env.mem and env.mem.disconnect then env.mem:disconnect() end + if env.search and env.search.disconnect then env.search:disconnect() end if env.mem or env.search or env.db_table then env.db_table = nil env.mem = nil