librime-lua icon indicating copy to clipboard operation
librime-lua copied to clipboard

Memory 组件不能调用 FinishSession,使得对用户词典的写入有延迟

Open tansongchen opened this issue 6 months ago • 1 comments

在使用中,观察到以下现象:如果使用 Memory 的 update_userdict() 函数更新了用户词典,则这个更新的内容一般不会立刻反映出来,但如果按了回车等 Rime 不会处理的键,就能立刻反映出来。我认为原因是:TableTranslator 和 ScriptTranslator 都在一开始调用了 FinishSession() 这个函数,以保证上一次的写入生效,但是 lua 中的 Memory 没有暴露这个函数,因此无法调用。

建议把

  bool StartSession();
  bool FinishSession();
  bool DiscardSession();

这几个函数也加入 lua 接口,方便开发者调用。

tansongchen avatar Feb 13 '24 18:02 tansongchen

你可以試試在https://github.com/hchunhui/librime-lua/blob/7f3eca2ce659fc2401b8acb52bd2182b433e12b1/src/types.cc#L1656 加入 memory.FinishSession();

shewer avatar Feb 14 '24 08:02 shewer