fix confirm resolve
This commit is contained in:
@@ -440,6 +440,11 @@ performance.fetching_timeout~
|
|||||||
Sets the timeout of candidate fetching process.
|
Sets the timeout of candidate fetching process.
|
||||||
The nvim-cmp will wait to display the most prioritized source.
|
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*
|
*cmp-config.performance.async_budget*
|
||||||
performance.async_budget~
|
performance.async_budget~
|
||||||
`number`
|
`number`
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ return function()
|
|||||||
debounce = 60,
|
debounce = 60,
|
||||||
throttle = 30,
|
throttle = 30,
|
||||||
fetching_timeout = 500,
|
fetching_timeout = 500,
|
||||||
|
confirm_resolve_timeout = 80,
|
||||||
async_budget = 1,
|
async_budget = 1,
|
||||||
max_view_entries = 200,
|
max_view_entries = 200,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local debug = require('cmp.utils.debug')
|
local debug = require('cmp.utils.debug')
|
||||||
local str = require('cmp.utils.str')
|
local str = require('cmp.utils.str')
|
||||||
local char = require('cmp.utils.char')
|
local char = require('cmp.utils.char')
|
||||||
local pattern = require('cmp.utils.pattern')
|
|
||||||
local feedkeys = require('cmp.utils.feedkeys')
|
local feedkeys = require('cmp.utils.feedkeys')
|
||||||
local async = require('cmp.utils.async')
|
local async = require('cmp.utils.async')
|
||||||
local keymap = require('cmp.utils.keymap')
|
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())
|
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()
|
local release = self:suspend()
|
||||||
|
|
||||||
-- Close menus.
|
-- Close menus.
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ source.reset = function(self)
|
|||||||
self.request_offset = -1
|
self.request_offset = -1
|
||||||
self.completion_context = nil
|
self.completion_context = nil
|
||||||
self.status = source.SourceStatus.WAITING
|
self.status = source.SourceStatus.WAITING
|
||||||
self.complete_dedup(function() end)
|
self.complete_dedup(function()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Return source config
|
---Return source config
|
||||||
@@ -90,12 +91,14 @@ source.get_entries = function(self, ctx)
|
|||||||
|
|
||||||
local target_entries = self.entries
|
local target_entries = self.entries
|
||||||
|
|
||||||
local prev = self.cache:get({ 'get_entries', tostring(self.revision) })
|
if not self.incomplete then
|
||||||
if prev and ctx.cursor.row == prev.ctx.cursor.row and self.offset == prev.offset then
|
local prev = self.cache:get({ 'get_entries', tostring(self.revision) })
|
||||||
-- only use prev entries when cursor is moved forward.
|
if prev and ctx.cursor.row == prev.ctx.cursor.row and self.offset == prev.offset then
|
||||||
-- and the pattern offset is the same.
|
-- only use prev entries when cursor is moved forward.
|
||||||
if prev.ctx.cursor.col <= ctx.cursor.col then
|
-- and the pattern offset is the same.
|
||||||
target_entries = prev.entries
|
if prev.ctx.cursor.col <= ctx.cursor.col then
|
||||||
|
target_entries = prev.entries
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -128,7 +131,9 @@ source.get_entries = function(self, ctx)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.cache:set({ 'get_entries', tostring(self.revision) }, { entries = entries, ctx = ctx, offset = self.offset })
|
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
|
if self:get_source_config().max_item_count then
|
||||||
local limited_entries = {}
|
local limited_entries = {}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ cmp.ItemField = {
|
|||||||
---@field public debounce integer
|
---@field public debounce integer
|
||||||
---@field public throttle integer
|
---@field public throttle integer
|
||||||
---@field public fetching_timeout 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 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
|
---@field public max_view_entries integer
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user