fix confirm resolve
This commit is contained in:
@@ -19,6 +19,7 @@ return function()
|
||||
debounce = 60,
|
||||
throttle = 30,
|
||||
fetching_timeout = 500,
|
||||
confirm_resolve_timeout = 80,
|
||||
async_budget = 1,
|
||||
max_view_entries = 200,
|
||||
},
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,12 +91,14 @@ source.get_entries = function(self, ctx)
|
||||
|
||||
local target_entries = self.entries
|
||||
|
||||
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.
|
||||
-- and the pattern offset is the same.
|
||||
if prev.ctx.cursor.col <= ctx.cursor.col then
|
||||
target_entries = prev.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.
|
||||
-- and the pattern offset is the same.
|
||||
if prev.ctx.cursor.col <= ctx.cursor.col then
|
||||
target_entries = prev.entries
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,7 +131,9 @@ source.get_entries = function(self, ctx)
|
||||
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
|
||||
local limited_entries = {}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user