Improve scheduling
This commit is contained in:
@@ -149,7 +149,7 @@ end
|
|||||||
---Invoke completion
|
---Invoke completion
|
||||||
---@param ctx cmp.Context
|
---@param ctx cmp.Context
|
||||||
core.complete = function(ctx)
|
core.complete = function(ctx)
|
||||||
local callback = vim.schedule_wrap(function()
|
local callback = function()
|
||||||
local new = context.new(ctx)
|
local new = context.new(ctx)
|
||||||
if new:changed(new.prev_context) then
|
if new:changed(new.prev_context) then
|
||||||
core.complete(new)
|
core.complete(new)
|
||||||
@@ -157,7 +157,7 @@ core.complete = function(ctx)
|
|||||||
core.filter.timeout = 50
|
core.filter.timeout = 50
|
||||||
core.filter()
|
core.filter()
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
for _, s in ipairs(core.get_sources()) do
|
for _, s in ipairs(core.get_sources()) do
|
||||||
s:complete(ctx, callback)
|
s:complete(ctx, callback)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ source.complete = function(self, ctx, callback)
|
|||||||
option = self:get_option(),
|
option = self:get_option(),
|
||||||
completion_context = completion_context,
|
completion_context = completion_context,
|
||||||
},
|
},
|
||||||
self.complete_dedup(function(response)
|
self.complete_dedup(vim.schedule_wrap(function(response)
|
||||||
self.revision = self.revision + 1
|
self.revision = self.revision + 1
|
||||||
if (misc.safe(response) and misc.safe(response.items) or misc.safe(response)) ~= nil then
|
if (misc.safe(response) and misc.safe(response.items) or misc.safe(response)) ~= nil then
|
||||||
debug.log(self:get_debug_name(), 'retrieve', #(response.items or response))
|
debug.log(self:get_debug_name(), 'retrieve', #(response.items or response))
|
||||||
@@ -308,7 +308,7 @@ source.complete = function(self, ctx, callback)
|
|||||||
self.status = prev_status
|
self.status = prev_status
|
||||||
end
|
end
|
||||||
callback()
|
callback()
|
||||||
end)
|
end))
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user