@@ -456,6 +456,12 @@ 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.filtering_context_budget*
|
||||||
|
performance.filtering_context_budget~
|
||||||
|
`number`
|
||||||
|
Sets the filtering context budget in ms.
|
||||||
|
If filtering takes longer than this, it will be deferred.
|
||||||
|
|
||||||
*cmp-config.performance.confirm_resolve_timeout*
|
*cmp-config.performance.confirm_resolve_timeout*
|
||||||
performance.confirm_resolve_timeout~
|
performance.confirm_resolve_timeout~
|
||||||
`number`
|
`number`
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ return function()
|
|||||||
debounce = 60,
|
debounce = 60,
|
||||||
throttle = 30,
|
throttle = 30,
|
||||||
fetching_timeout = 500,
|
fetching_timeout = 500,
|
||||||
|
filtering_context_budget = 3,
|
||||||
confirm_resolve_timeout = 80,
|
confirm_resolve_timeout = 80,
|
||||||
async_budget = 1,
|
async_budget = 1,
|
||||||
max_view_entries = 200,
|
max_view_entries = 200,
|
||||||
|
|||||||
@@ -61,7 +61,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
|
||||||
@@ -111,6 +112,9 @@ source.get_entries = function(self, ctx)
|
|||||||
---@type cmp.Entry[]
|
---@type cmp.Entry[]
|
||||||
local entries = {}
|
local entries = {}
|
||||||
local matching_config = self:get_matching_config()
|
local matching_config = self:get_matching_config()
|
||||||
|
local filtering_context_budget = config.get().performance.filtering_context_budget / 1000
|
||||||
|
|
||||||
|
local s = os.clock()
|
||||||
for _, e in ipairs(target_entries) do
|
for _, e in ipairs(target_entries) do
|
||||||
local o = e.offset
|
local o = e.offset
|
||||||
if not inputs[o] then
|
if not inputs[o] then
|
||||||
@@ -128,10 +132,14 @@ source.get_entries = function(self, ctx)
|
|||||||
entries[#entries + 1] = e
|
entries[#entries + 1] = e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if os.clock() - s > filtering_context_budget then
|
||||||
async.yield()
|
async.yield()
|
||||||
if ctx.aborted then
|
if ctx.aborted then
|
||||||
async.abort()
|
async.abort()
|
||||||
end
|
end
|
||||||
|
s = os.clock()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.incomplete then
|
if not self.incomplete then
|
||||||
|
|||||||
@@ -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 filtering_context_budget integer
|
||||||
---@field public confirm_resolve_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