* fix(#1676): remove_keymaps matches case insensitively * fix(#1676): mappings.list.n.key matches case insensitively for overrides
This commit is contained in:
parent
58055a0397
commit
5a798b3be0
@ -291,15 +291,19 @@ local function merge_mappings(user_mappings)
|
|||||||
for _, map in pairs(user_mappings) do
|
for _, map in pairs(user_mappings) do
|
||||||
if type(map.key) == "table" then
|
if type(map.key) == "table" then
|
||||||
for _, key in pairs(map.key) do
|
for _, key in pairs(map.key) do
|
||||||
table.insert(user_keys, key)
|
if type(key) == "string" then
|
||||||
if is_empty(map.action) then
|
table.insert(user_keys, key:lower())
|
||||||
table.insert(removed_keys, key)
|
if is_empty(map.action) then
|
||||||
|
table.insert(removed_keys, key:lower())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.insert(user_keys, map.key)
|
if type(map.key) == "string" then
|
||||||
if is_empty(map.action) then
|
table.insert(user_keys, map.key:lower())
|
||||||
table.insert(removed_keys, map.key)
|
if is_empty(map.action) then
|
||||||
|
table.insert(removed_keys, map.key:lower())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -316,14 +320,19 @@ local function merge_mappings(user_mappings)
|
|||||||
if type(map.key) == "table" then
|
if type(map.key) == "table" then
|
||||||
local filtered_keys = {}
|
local filtered_keys = {}
|
||||||
for _, key in pairs(map.key) do
|
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)
|
table.insert(filtered_keys, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
map.key = filtered_keys
|
map.key = filtered_keys
|
||||||
return not vim.tbl_isempty(map.key)
|
return not vim.tbl_isempty(map.key)
|
||||||
else
|
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
|
||||||
end, M.mappings)
|
end, M.mappings)
|
||||||
|
|
||||||
@ -366,14 +375,17 @@ local function filter_mappings(mappings, keys)
|
|||||||
if type(keys) == "boolean" and keys then
|
if type(keys) == "boolean" and keys then
|
||||||
return {}
|
return {}
|
||||||
elseif type(keys) == "table" then
|
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)
|
return vim.tbl_filter(function(m)
|
||||||
if type(m.key) == "table" then
|
if type(m.key) == "table" then
|
||||||
m.key = vim.tbl_filter(function(k)
|
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)
|
end, m.key)
|
||||||
return #m.key > 0
|
return #m.key > 0
|
||||||
else
|
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
|
||||||
end, vim.deepcopy(mappings))
|
end, vim.deepcopy(mappings))
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user