Improve first display
This commit is contained in:
@@ -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(
|
|
||||||
ctx,
|
|
||||||
(function(src)
|
|
||||||
local callback
|
local callback
|
||||||
callback = function()
|
callback = (function(s_)
|
||||||
|
return function ()
|
||||||
local new = context.new(ctx)
|
local new = context.new(ctx)
|
||||||
if new:changed(new.prev_context) and ctx == self.context then
|
if new:changed(s_.context) then
|
||||||
src:complete(new, callback)
|
s_:complete(new, callback)
|
||||||
else
|
else
|
||||||
self.filter.stop()
|
for _, s__ in ipairs(self:get_sources({ source.SourceStatus.FETCHING })) do
|
||||||
self.filter.timeout = DEBOUNCE_TIME
|
if s_ == s__ then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if not s__.incomplete and SOURCE_TIMEOUT > s__:get_fetching_time() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
|
||||||
self:filter()
|
self:filter()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return callback
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user