This commit is contained in:
hrsh7th
2021-10-19 14:55:14 +09:00
parent 775a371660
commit 26e73f3140
2 changed files with 4 additions and 2 deletions

View File

@@ -446,7 +446,7 @@ Return the completion menu is visible or not.
NOTE: This method returns true if the native popup menu is visible. For convenience to define mappings.
#### `cmp.confirm({ select = boolean, behavior = cmp.ConfirmBehavior.{Insert,Replace} })`
#### `cmp.confirm({ select = boolean, behavior = cmp.ConfirmBehavior.{Insert,Replace} }, callback)`
Confirm current selected item if possible.

View File

@@ -142,8 +142,9 @@ cmp.scroll_docs = function(delta)
end
---Confirm completion
cmp.confirm = function(option)
cmp.confirm = function(option, callback)
option = option or {}
callback = callback or function() end
-- Hack: Ignore when executing macro.
if vim.fn.reg_executing() ~= '' then
@@ -155,6 +156,7 @@ cmp.confirm = function(option)
cmp.core:confirm(e, {
behavior = option.behavior,
}, function()
callback()
cmp.core:complete(cmp.core:get_context({ reason = cmp.ContextReason.TriggerOnly }))
end)
return true