Skip to content

Commit

Permalink
disable does not prevent errors if you call update before you check i…
Browse files Browse the repository at this point in the history
…f enabled.
  • Loading branch information
BirdeeHub committed Feb 22, 2024
1 parent 4433e5e commit a888166
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/which-key/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,13 @@ function M.update(buf)
if tree.buf and not vim.api.nvim_buf_is_valid(tree.buf) then
-- remove group for invalid buffers
M.mappings[k] = nil
elseif not buf or not tree.buf or buf == tree.buf then
elseif not buf or not tree.buf or buf == tree.buf or
require("which-key.view").is_enabled(buf) then
-- only update buffer maps, if:
-- 1. we dont pass a buffer
-- 2. this is a global node
-- 3. this is a local buffer node for the passed buffer
-- 4. which-key is enabled for the buffer.
M.update_keymaps(tree.mode, tree.buf)
M.add_hooks(tree.mode, tree.buf, tree.tree.root)
end
Expand Down

0 comments on commit a888166

Please sign in to comment.