Skip to content

Commit

Permalink
fix(keys): properly deal with ft list for keys. Fixes #1448
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 21, 2024
1 parent 9895337 commit 82cf974
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,14 @@ end
function M:_del(keys)
-- bufs will be all buffers of the filetype for a buffer-local mapping
-- OR `false` for a global mapping
local bufs = keys.ft
and vim.tbl_filter(function(buf)
return vim.bo[buf].filetype == keys.ft
end, vim.api.nvim_list_bufs())
or { false }
local bufs = { false }

if keys.ft then
local ft = type(keys.ft) == "string" and { keys.ft } or keys.ft --[[@as string[] ]]
bufs = vim.tbl_filter(function(buf)
return vim.tbl_contains(ft, vim.bo[buf].filetype)
end, vim.api.nvim_list_bufs())
end

for _, buf in ipairs(bufs) do
pcall(vim.keymap.del, keys.mode, keys.lhs, { buffer = buf or nil })
Expand Down

0 comments on commit 82cf974

Please sign in to comment.