Closed bczhc closed 11 months ago
the notifier needed to disconnect . fixed code
return {
func = function(_, _)
return kNoop
end,
init = function(env)
env.notifier= env.engine.context.commit_notifier:connect(
function(ctx)
local commit_text = ctx:get_commit_text()
my_log_on_commit(commit_text)
end)
end,
fini(env)
env.notifier:disconnect()
end
}
This works. Thanks for the help!
Saying now I want to make a commit logger using rime-lua, then write a processor like this:
On fcitx5's initial startup, this works fine. But fcitx5 will do automatic syncing^1, and after an "autosave", the
commit_notifier
will be no longer registered. After the autosave,init_flag
is still true, so the notifier won't be connected again. As a result, when I start typing then, the commit logger doesn't work anymore.However, if I don't use an init flag, and change the code as this:
the commit notifier will be registered twice, resulting in a redundant log event after an autosave:
Steps to reproduce
Result
The two cases I mentioned above.
Notes
You can modify the code of fcitx5 and shrink the autosave interval from 30min to ~30 secs.
Versions
fcitx5
: 5.1.6@a4e4311fcitx5-rime
: 5.1.3@303a3fe