feat: select_next_item and select_prev_item support "count" option. deafults to 1 (#1262)

User can increase count value to select item with pagedown/pageup.

- cmp.select_prev_item({ behavior = behavior, count = 8 })
- cmp.select_next_item({ behavior = behavior, count = 8 })
This commit is contained in:
ADoyle
2022-11-09 18:26:20 +08:00
committed by GitHub
parent c8d4afdad6
commit bdfadc1238
5 changed files with 72 additions and 33 deletions

View File

@@ -122,9 +122,9 @@ native_entries_view.select_next_item = function(self, option)
end
if self:visible() then
if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then
feedkeys.call(keymap.t('<C-n>'), 'n', callback)
feedkeys.call(keymap.t(string.format('%s<C-n>', option.count), 'n', callback))
else
feedkeys.call(keymap.t('<Down>'), 'n', callback)
feedkeys.call(keymap.t(string.format('%s<Down>', option.count)), 'n', callback)
end
end
end
@@ -135,9 +135,9 @@ native_entries_view.select_prev_item = function(self, option)
end
if self:visible() then
if (option.behavior or types.cmp.SelectBehavior.Insert) == types.cmp.SelectBehavior.Insert then
feedkeys.call(keymap.t('<C-p>'), 'n', callback)
feedkeys.call(keymap.t(string.format('%s<C-p>', option.count), 'n', callback))
else
feedkeys.call(keymap.t('<Up>'), 'n', callback)
feedkeys.call(keymap.t(string.format('%s<Up>', option.count)), 'n', callback)
end
end
end