Skip to content

Commit

Permalink
fix(state): don't show when coming from cmdline mode. Fixes #692
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 14, 2024
1 parent c77cda8 commit 8cba66b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 9 additions & 1 deletion lua/which-key/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ local M = {}
---@type wk.State?
M.state = nil

function M.safe(mode_change)
local old, _new = unpack(vim.split(mode_change, ":", { plain = true }))
if old == "c" then
return false
end
return vim.fn.reg_recording() == "" and vim.fn.reg_executing() == "" and vim.fn.getcharstr(1) == ""
end

function M.setup()
local group = vim.api.nvim_create_augroup("wk", { clear = true })

Expand Down Expand Up @@ -62,7 +70,7 @@ function M.setup()
if cooldown() then
return
end
if not Util.safe() then
if not M.safe(ev.match) then
-- dont start when recording or when chars are pending
Util.debug("not safe")
cooldown(true) -- cooldown till next tick
Expand Down
4 changes: 0 additions & 4 deletions lua/which-key/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ function M.xo()
return M.mapmode():find("[xo]") ~= nil
end

function M.safe()
return vim.fn.reg_recording() == "" and vim.fn.reg_executing() == "" and vim.fn.getcharstr(1) == ""
end

---@alias NotifyOpts {level?: number, title?: string, once?: boolean, id?:string}

---@param msg string|string[]
Expand Down

0 comments on commit 8cba66b

Please sign in to comment.