Improve first display

This commit is contained in:
hrsh7th
2021-11-19 16:56:36 +09:00
parent c2a9e0ccaa
commit 1c7f73aa4a

View File

@@ -224,23 +224,27 @@ core.complete = function(self, ctx)
self:set_context(ctx) self:set_context(ctx)
for _, s in ipairs(self:get_sources({ source.SourceStatus.WAITING, source.SourceStatus.COMPLETED })) do for _, s in ipairs(self:get_sources({ source.SourceStatus.WAITING, source.SourceStatus.COMPLETED })) do
s:complete( local callback
ctx, callback = (function(s_)
(function(src) return function ()
local callback local new = context.new(ctx)
callback = function() if new:changed(s_.context) then
local new = context.new(ctx) s_:complete(new, callback)
if new:changed(new.prev_context) and ctx == self.context then else
src:complete(new, callback) for _, s__ in ipairs(self:get_sources({ source.SourceStatus.FETCHING })) do
else if s_ == s__ then
self.filter.stop() break
self.filter.timeout = DEBOUNCE_TIME end
self:filter() if not s__.incomplete and SOURCE_TIMEOUT > s__:get_fetching_time() then
return
end
end end
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
self:filter()
end end
return callback end
end)(s) end)(s)
) s:complete(ctx, callback)
end end
self.filter.timeout = THROTTLE_TIME self.filter.timeout = THROTTLE_TIME
@@ -250,6 +254,8 @@ end
---Update completion menu ---Update completion menu
core.filter = async.throttle( core.filter = async.throttle(
vim.schedule_wrap(function(self) vim.schedule_wrap(function(self)
self.filter.timeout = THROTTLE_TIME
local ignore = false local ignore = false
ignore = ignore or not api.is_suitable_mode() ignore = ignore or not api.is_suitable_mode()
ignore = ignore or self.view:get_active_entry() ignore = ignore or self.view:get_active_entry()
@@ -259,8 +265,7 @@ core.filter = async.throttle(
local sources = {} local sources = {}
for _, s in ipairs(self:get_sources({ source.SourceStatus.FETCHING, source.SourceStatus.COMPLETED })) do for _, s in ipairs(self:get_sources({ source.SourceStatus.FETCHING, source.SourceStatus.COMPLETED })) do
local time = SOURCE_TIMEOUT - s:get_fetching_time() if not s.incomplete and SOURCE_TIMEOUT > s:get_fetching_time() then
if not s.incomplete and time > 0 then
break break
end end
table.insert(sources, s) table.insert(sources, s)