Skip to content

Commit 0753a44

Browse files
dfrommiAntoineGS
authored andcommitted
feat: add has_next() function to suggestion
Allow skipping next-cycle by checking has_next() before next()
1 parent e405f02 commit 0753a44

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/copilot/suggestion/init.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,17 @@ local function get_suggestions_cycling(callback, ctx)
453453
end
454454
end
455455

456+
function M.has_next()
457+
local ctx = get_ctx()
458+
459+
-- no completions at all
460+
if not ctx.suggestions or #ctx.suggestions == 0 then
461+
return false
462+
end
463+
464+
return (ctx.choice < #ctx.suggestions or not ctx.cycling)
465+
end
466+
456467
local function advance(count, ctx)
457468
if ctx ~= get_ctx() then
458469
return

0 commit comments

Comments
 (0)