Skip to content

Commit

Permalink
fix: respect opts.index when checking if cmp.accept can be run
Browse files Browse the repository at this point in the history
Closes #633
  • Loading branch information
Saghen committed Dec 18, 2024
1 parent 3436a20 commit ea12c51
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/blink/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ end

--- @param opts? blink.cmp.CompletionListAcceptOpts
function cmp.accept(opts)
opts = opts or {}
if not cmp.is_visible() then return end

local completion_list = require('blink.cmp.completion.list')
local item = completion_list.get_selected_item()
local item = opts.index ~= nil and completion_list.items[opts.index] or completion_list.get_selected_item()
if item == nil then return end

vim.schedule(function() completion_list.accept(opts) end)
Expand Down

0 comments on commit ea12c51

Please sign in to comment.