Skip to content

Commit

Permalink
Fix mapping normalization order
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Apr 13, 2022
1 parent f4b3dda commit 0c1f37c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lua/cmp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ config.get = function()
global_config.revision or 0,
onetime_config.revision or 0,
}, function()
return config.normalize(misc.merge(onetime_config, global_config))
return misc.merge(config.normalize(onetime_config), config.normalize(global_config))
end)
elseif api.is_cmdline_mode() then
local cmdtype = vim.fn.getcmdtype()
Expand All @@ -94,7 +94,7 @@ config.get = function()
cmdtype,
cmdline_config.revision or 0,
}, function()
return config.normalize(misc.merge(cmdline_config, global_config))
return misc.merge(config.normalize(cmdline_config), misc.merge(global_config))
end)
else
local bufnr = vim.api.nvim_get_current_buf()
Expand All @@ -111,9 +111,9 @@ config.get = function()
buffer_config.revision or 0,
}, function()
local c = {}
c = config.normalize(misc.merge(c, buffer_config))
c = config.normalize(misc.merge(c, filetype_config))
c = config.normalize(misc.merge(c, global_config))
c = misc.merge(config.normalize(c), config.normalize(buffer_config))
c = misc.merge(config.normalize(c), config.normalize(filetype_config))
c = misc.merge(config.normalize(c), config.normalize(global_config))
return c
end)
end
Expand Down
7 changes: 5 additions & 2 deletions lua/cmp/config/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mapping.preset.cmdline = function(override)
if cmp.visible() then
cmp.select_next_item()
else
cmp.complete()
cmp.complete({ reason = cmp.ContextReason.Manual })
end
end
},
Expand All @@ -60,7 +60,7 @@ mapping.preset.cmdline = function(override)
if cmp.visible() then
cmp.select_prev_item()
else
cmp.complete()
cmp.complete({ reason = cmp.ContextReason.Manual })
end
end
},
Expand All @@ -84,6 +84,9 @@ mapping.preset.cmdline = function(override)
end
end
},
['<C-e>'] = {
c = mapping.close(),
},
})
end

Expand Down
12 changes: 12 additions & 0 deletions lua/cmp/utils/misc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ describe('misc', function()
})
assert.are.equal(merged.a.b, 1)

merged = misc.merge({
a = {
i = 1,
},
}, {
a = {
c = 2,
},
})
assert.are.equal(merged.a.i, 1)
assert.are.equal(merged.a.c, 2)

merged = misc.merge({
a = false,
}, {
Expand Down

0 comments on commit 0c1f37c

Please sign in to comment.