Files
rime-ice/lua/en_spacer.lua
wrvsrx aa505b7b2d !refactor: Lua 模块引用方式变更 (#1094)
- 删除了 `rime.lua`
- 在方案中引用时添加 `*` 前缀
2024-12-06 00:11:43 +08:00

19 lines
667 B
Lua

-- 英文词条上屏自动添加空格
-- 在 engine/filters 的倒数第二个位置,增加 - lua_filter@en_spacer
--
-- 英文后,再输入英文单词(必须为候选项)自动添加空格
local F = {}
function F.func( input, env )
local latest_text = env.engine.context.commit_history:latest_text()
for cand in input:iter() do
if cand.text:match( '^[%a\']+[%a\']*$' ) and latest_text and #latest_text > 0 and
latest_text:find( '^ ?[%a\']+[%a\']*$' ) then
cand = cand:to_shadow_candidate( 'en_spacer', cand.text:gsub( '(%a+\'?%a*)', ' %1' ), cand.comment )
end
yield( cand )
end
end
return F