Skip to content

Commit 796a00e

Browse files
committed
feat: add count option to select_next and select_prev
Closes #569
1 parent 277203b commit 796a00e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/blink/cmp/completion/list.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
--- @field accept fun(opts?: blink.cmp.CompletionListAcceptOpts): boolean Applies the currently selected item, returning true if it succeeded
2828

2929
--- @class blink.cmp.CompletionListSelectOpts
30+
--- @field count? number The number of items to jump by, defaults to 1
3031
--- @field auto_insert? boolean Insert the completion item automatically when selecting it
3132
--- @field on_ghost_text? boolean Run when ghost text is visible, instead of only when the menu is visible
3233

@@ -198,7 +199,8 @@ function list.select_next(opts)
198199
end
199200

200201
-- typical case, select the next item
201-
list.select(list.selected_item_idx + 1, opts)
202+
local count = opts and opts.count or 1
203+
list.select(math.min(list.selected_item_idx + count, #list.items), opts)
202204
end
203205

204206
function list.select_prev(opts)
@@ -225,7 +227,8 @@ function list.select_prev(opts)
225227
end
226228

227229
-- typical case, select the previous item
228-
list.select(list.selected_item_idx - 1, opts)
230+
local count = opts and opts.count or 1
231+
list.select(math.max(list.selected_item_idx - count, 1), opts)
229232
end
230233

231234
---------- Preview ----------

0 commit comments

Comments
 (0)