Revert "fix(#1676) case insensitive mapping key remove and override (#1682)"

This reverts commit 5a798b3be0.
This commit is contained in:
Alexander Courtis 2022-10-25 08:00:17 +11:00
parent 23c0fe9a0a
commit 49c32c0dda

View File

@ -291,19 +291,15 @@ 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
if type(key) == "string" then
table.insert(user_keys, key:lower())
if is_empty(map.action) then
table.insert(removed_keys, key:lower())
end
table.insert(user_keys, key)
if is_empty(map.action) then
table.insert(removed_keys, key)
end
end
else
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
table.insert(user_keys, map.key)
if is_empty(map.action) then
table.insert(removed_keys, map.key)
end
end
@ -320,19 +316,14 @@ local function merge_mappings(user_mappings)
if type(map.key) == "table" then
local filtered_keys = {}
for _, key in pairs(map.key) do
if
type(key) == "string"
and not vim.tbl_contains(user_keys, key:lower())
and not vim.tbl_contains(removed_keys, key:lower())
then
if not vim.tbl_contains(user_keys, key) and not vim.tbl_contains(removed_keys, key) then
table.insert(filtered_keys, key)
end
end
map.key = filtered_keys
return not vim.tbl_isempty(map.key)
else
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())
return not vim.tbl_contains(user_keys, map.key) and not vim.tbl_contains(removed_keys, map.key)
end
end, M.mappings)
@ -375,17 +366,14 @@ 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 type(k) ~= "string" or not vim.tbl_contains(keys_lower, k:lower())
return not vim.tbl_contains(keys, k)
end, m.key)
return #m.key > 0
else
return type(m.key) ~= "string" or not vim.tbl_contains(keys_lower, m.key:lower())
return not vim.tbl_contains(keys, m.key)
end
end, vim.deepcopy(mappings))
else