fix confirm resolve

This commit is contained in:
hrsh7th
2023-06-23 13:29:24 +09:00
parent 8a1694ff33
commit 9e49ed3fee
5 changed files with 24 additions and 9 deletions

View File

@@ -440,6 +440,11 @@ performance.fetching_timeout~
Sets the timeout of candidate fetching process.
The nvim-cmp will wait to display the most prioritized source.
*cmp-config.performance.confirm_resolve_timeout*
performance.confirm_resolve_timeout~
`number`
Sets the timeout for resolving item before confirmation.
*cmp-config.performance.async_budget*
performance.async_budget~
`number`

View File

@@ -19,6 +19,7 @@ return function()
debounce = 60,
throttle = 30,
fetching_timeout = 500,
confirm_resolve_timeout = 80,
async_budget = 1,
max_view_entries = 200,
},

View File

@@ -1,7 +1,6 @@
local debug = require('cmp.utils.debug')
local str = require('cmp.utils.str')
local char = require('cmp.utils.char')
local pattern = require('cmp.utils.pattern')
local feedkeys = require('cmp.utils.feedkeys')
local async = require('cmp.utils.async')
local keymap = require('cmp.utils.keymap')
@@ -363,6 +362,10 @@ core.confirm = function(self, e, option, callback)
debug.log('entry.confirm', e:get_completion_item())
async.sync(function(done)
e:resolve(done)
end, config.get().performance.confirm_resolve_timeout)
local release = self:suspend()
-- Close menus.

View File

@@ -57,7 +57,8 @@ source.reset = function(self)
self.request_offset = -1
self.completion_context = nil
self.status = source.SourceStatus.WAITING
self.complete_dedup(function() end)
self.complete_dedup(function()
end)
end
---Return source config
@@ -90,6 +91,7 @@ source.get_entries = function(self, ctx)
local target_entries = self.entries
if not self.incomplete then
local prev = self.cache:get({ 'get_entries', tostring(self.revision) })
if prev and ctx.cursor.row == prev.ctx.cursor.row and self.offset == prev.offset then
-- only use prev entries when cursor is moved forward.
@@ -98,6 +100,7 @@ source.get_entries = function(self, ctx)
target_entries = prev.entries
end
end
end
local entry_filter = self:get_entry_filter()
@@ -128,7 +131,9 @@ source.get_entries = function(self, ctx)
end
end
if not self.incomplete then
self.cache:set({ 'get_entries', tostring(self.revision) }, { entries = entries, ctx = ctx, offset = self.offset })
end
if self:get_source_config().max_item_count then
local limited_entries = {}

View File

@@ -103,6 +103,7 @@ cmp.ItemField = {
---@field public debounce integer
---@field public throttle integer
---@field public fetching_timeout integer
---@field public confirm_resolve_timeout integer
---@field public async_budget integer Maximum time (in ms) an async function is allowed to run during one step of the event loop.
---@field public max_view_entries integer