From 7007436882eebecf0bfbc66e6df1ec4a02a0b55d Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 24 Oct 2022 14:09:34 +1100 Subject: [PATCH 1/2] fix(#1676): remove_keymaps matches case insensitively --- lua/nvim-tree/actions/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index d755a559ba5..5a938837b3f 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -366,14 +366,17 @@ local function filter_mappings(mappings, keys) if type(keys) == "boolean" and keys then return {} elseif type(keys) == "table" then + local keys_lower = vim.tbl_map(function(k) + return type(k) == "string" and k:lower() or nil + end, keys) return vim.tbl_filter(function(m) if type(m.key) == "table" then m.key = vim.tbl_filter(function(k) - return not vim.tbl_contains(keys, k) + return type(k) ~= "string" or not vim.tbl_contains(keys_lower, k:lower()) end, m.key) return #m.key > 0 else - return not vim.tbl_contains(keys, m.key) + return type(m.key) ~= "string" or not vim.tbl_contains(keys_lower, m.key:lower()) end end, vim.deepcopy(mappings)) else From 0e53db1c7dfaea81135020ac95170bcc3b63932a Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 24 Oct 2022 14:30:28 +1100 Subject: [PATCH 2/2] fix(#1676): mappings.list.n.key matches case insensitively for overrides --- lua/nvim-tree/actions/init.lua | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index 5a938837b3f..5ae6899c964 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -291,15 +291,19 @@ local function merge_mappings(user_mappings) for _, map in pairs(user_mappings) do if type(map.key) == "table" then for _, key in pairs(map.key) do - table.insert(user_keys, key) - if is_empty(map.action) then - table.insert(removed_keys, key) + if type(key) == "string" then + table.insert(user_keys, key:lower()) + if is_empty(map.action) then + table.insert(removed_keys, key:lower()) + end end end else - table.insert(user_keys, map.key) - if is_empty(map.action) then - table.insert(removed_keys, map.key) + if type(map.key) == "string" then + table.insert(user_keys, map.key:lower()) + if is_empty(map.action) then + table.insert(removed_keys, map.key:lower()) + end end end @@ -316,14 +320,19 @@ local function merge_mappings(user_mappings) if type(map.key) == "table" then local filtered_keys = {} for _, key in pairs(map.key) do - if not vim.tbl_contains(user_keys, key) and not vim.tbl_contains(removed_keys, key) then + if + type(key) == "string" + and not vim.tbl_contains(user_keys, key:lower()) + and not vim.tbl_contains(removed_keys, key:lower()) + then table.insert(filtered_keys, key) end end map.key = filtered_keys return not vim.tbl_isempty(map.key) else - return not vim.tbl_contains(user_keys, map.key) and not vim.tbl_contains(removed_keys, map.key) + return type(map.key) ~= "string" + or not vim.tbl_contains(user_keys, map.key:lower()) and not vim.tbl_contains(removed_keys, map.key:lower()) end end, M.mappings)