From 2e4270d02843d15510b3549354e238788ca07ca5 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Wed, 24 Nov 2021 12:57:04 +0900 Subject: [PATCH] Improve incomplete handling --- lua/cmp/core.lua | 20 ++++++++++---------- lua/cmp/source.lua | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/cmp/core.lua b/lua/cmp/core.lua index 39afa87..24e9017 100644 --- a/lua/cmp/core.lua +++ b/lua/cmp/core.lua @@ -222,7 +222,7 @@ core.complete = function(self, ctx) end 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()) do local callback callback = (function(s_) return function() @@ -230,17 +230,17 @@ core.complete = function(self, ctx) if s_.incomplete and new:changed(s_.context) then s_:complete(new, callback) else - for _, s__ in ipairs(self:get_sources({ source.SourceStatus.FETCHING })) do - if s_ == s__ then - break - end - if not s__.incomplete and SOURCE_TIMEOUT > s__:get_fetching_time() then - return - end + for _, s__ in ipairs(self:get_sources({ source.SourceStatus.FETCHING })) do + if s_ == s__ then + break + end + if not s__.incomplete and SOURCE_TIMEOUT > s__:get_fetching_time() then + return end - self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0 - self:filter() end + self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0 + self:filter() + end end end)(s) s:complete(ctx, callback) diff --git a/lua/cmp/source.lua b/lua/cmp/source.lua index 476cc94..0e171c0 100644 --- a/lua/cmp/source.lua +++ b/lua/cmp/source.lua @@ -255,7 +255,7 @@ source.complete = function(self, ctx, callback) } elseif ctx:get_reason() ~= types.cmp.ContextReason.TriggerOnly then if self:get_keyword_length() <= (ctx.cursor.col - offset) then - if self.incomplete and self.context.cursor.col ~= ctx.cursor.col then + if self.incomplete and self.context.cursor.col ~= ctx.cursor.col and self.status ~= source.SourceStatus.FETCHING then completion_context = { triggerKind = types.lsp.CompletionTriggerKind.TriggerForIncompleteCompletions, }