Improve scheduling

This commit is contained in:
hrsh7th
2021-08-27 21:34:34 +09:00
parent 63d6c22431
commit 61984efaf0
2 changed files with 4 additions and 4 deletions

View File

@@ -149,7 +149,7 @@ end
---Invoke completion
---@param ctx cmp.Context
core.complete = function(ctx)
local callback = vim.schedule_wrap(function()
local callback = function()
local new = context.new(ctx)
if new:changed(new.prev_context) then
core.complete(new)
@@ -157,7 +157,7 @@ core.complete = function(ctx)
core.filter.timeout = 50
core.filter()
end
end)
end
for _, s in ipairs(core.get_sources()) do
s:complete(ctx, callback)
end

View File

@@ -288,7 +288,7 @@ source.complete = function(self, ctx, callback)
option = self:get_option(),
completion_context = completion_context,
},
self.complete_dedup(function(response)
self.complete_dedup(vim.schedule_wrap(function(response)
self.revision = self.revision + 1
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))
@@ -308,7 +308,7 @@ source.complete = function(self, ctx, callback)
self.status = prev_status
end
callback()
end)
end))
)
return true
end