Skip to content

Commit b8e4c92

Browse files
committed
fix(state): improve detection of mode changing
1 parent 650f298 commit b8e4c92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lua/which-key/state.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ function M.setup()
9393
-- this prevents restarting which-key in the same tick
9494
vim.api.nvim_create_autocmd("ModeChanged", {
9595
group = group,
96-
callback = function(ev)
96+
callback = vim.schedule_wrap(function(ev)
9797
Util.trace("ModeChanged(" .. ev.match .. ")")
98-
local mode = Buf.get()
98+
local mode = Buf.get({ mode = ev.match:match(":(.+)") })
9999

100100
if cooldown() then
101101
Util.debug("cooldown")
@@ -121,7 +121,7 @@ function M.setup()
121121
M.stop()
122122
end
123123
Util.trace()
124-
end,
124+
end),
125125
})
126126

127127
vim.api.nvim_create_autocmd({ "LspAttach", "LspDetach" }, {

0 commit comments

Comments
 (0)