hchunhui / librime-lua

Extending RIME with Lua scripts
BSD 3-Clause "New" or "Revised" License
293 stars 43 forks source link

add disconnect to reset dict user_dict #338

Closed shewer closed 1 month ago

shewer commented 2 months ago

解決 librime Session clear() 時 ,掛在 env 的 component 還未清理 如 #335

mirtlebot commented 1 month ago

@hchunhui 请问能在有空的时候,review 下这个 PR 是否合适吗

hchunhui commented 1 month ago

看起来没问题。要是验证过可以解决原始问题的话我就合并了。@mirtlebot

mirtlebot commented 1 month ago

在 api_console 里面测试没问题,已经修复:

1711772797.webm

local F = {}

function F.init( env )
    env.foo = Memory( env.engine, env.engine.schema)
end

function F.func( input, env )
    for cand in input:iter() do
        cand.comment = '*' -- test this lua being called
        yield( cand )
    end
end

function F.fini(env)
    if env.foo.disconnect then
        print('disconnecting')
        env.foo:disconnect()
    else
        print('manual gc')
        env.foo = nil
        collectgarbage( 'collect' )
    end
end

return F
mirtlecn commented 1 month ago

@sci-42ver 你提的 bug 解决了,可以直接往里面写词汇了,可以将就着用了。

sci-42ver commented 1 month ago

@sci-42ver 你提的 bug 解决了,可以直接往里面写词汇了,可以将就着用了。

感谢提醒。Arch Linux librime作相应更新后,我试一下。