Fire change events when selecting different items with native menu completion (#514)

Previously we didn't do this, which resulted in the documentation window
not being shown when switching through different completion items. Fix
this by firing the change event in select_next_item and select_prev_item.
This commit is contained in:
Lyude
2021-11-27 03:43:40 -05:00
committed by GitHub
parent 9d48dd0d5b
commit a86017117b

View File

@@ -118,21 +118,27 @@ native_entries_view.preselect = function(self, index)
end end
native_entries_view.select_next_item = function(self, option) native_entries_view.select_next_item = function(self, option)
local callback = function()
self.event:emit('change')
end
if self:visible() then if self:visible() then
if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then
feedkeys.call(keymap.t('<C-n>'), 'n') feedkeys.call(keymap.t('<C-n>'), 'n', callback)
else else
feedkeys.call(keymap.t('<Down>'), 'n') feedkeys.call(keymap.t('<Down>'), 'n', callback)
end end
end end
end end
native_entries_view.select_prev_item = function(self, option) native_entries_view.select_prev_item = function(self, option)
local callback = function()
self.event:emit('change')
end
if self:visible() then if self:visible() then
if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then
feedkeys.call(keymap.t('<C-p>'), 'n') feedkeys.call(keymap.t('<C-p>'), 'n', callback)
else else
feedkeys.call(keymap.t('<Up>'), 'n') feedkeys.call(keymap.t('<Up>'), 'n', callback)
end end
end end
end end