From 82cf974e0939b3440c4470cbcd8e7869abfe480b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 21 May 2024 22:10:49 +0200 Subject: [PATCH] fix(keys): properly deal with ft list for keys. Fixes #1448 --- lua/lazy/core/handler/keys.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index 1d4ada3..bafc205 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -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 })