Reduce flicker
This commit is contained in:
@@ -16,7 +16,7 @@ local event = require('cmp.utils.event')
|
|||||||
|
|
||||||
local SOURCE_TIMEOUT = 500
|
local SOURCE_TIMEOUT = 500
|
||||||
local DEBOUNCE_TIME = 80
|
local DEBOUNCE_TIME = 80
|
||||||
local THROTTLE_TIME = 40
|
local THROTTLE_TIME = 60
|
||||||
|
|
||||||
---@class cmp.Core
|
---@class cmp.Core
|
||||||
---@field public suspending boolean
|
---@field public suspending boolean
|
||||||
@@ -276,17 +276,9 @@ core.complete = function(self, ctx)
|
|||||||
if s_.incomplete and new:changed(s_.context) then
|
if s_.incomplete and new:changed(s_.context) then
|
||||||
s_:complete(new, callback)
|
s_:complete(new, callback)
|
||||||
else
|
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
|
|
||||||
end
|
|
||||||
if not self.view:get_active_entry() then
|
if not self.view:get_active_entry() then
|
||||||
self.filter.stop()
|
self.filter.stop()
|
||||||
self.filter.timeout = self.view:visible() and DEBOUNCE_TIME or 0
|
self.filter.timeout = DEBOUNCE_TIME
|
||||||
self:filter()
|
self:filter()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -296,14 +288,14 @@ core.complete = function(self, ctx)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not self.view:get_active_entry() then
|
if not self.view:get_active_entry() then
|
||||||
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
|
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 1
|
||||||
self:filter()
|
self:filter()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Update completion menu
|
---Update completion menu
|
||||||
core.filter = async.throttle(function(self)
|
core.filter = async.throttle(function(self)
|
||||||
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
|
self.filter.timeout = THROTTLE_TIME
|
||||||
|
|
||||||
-- Check invalid condition.
|
-- Check invalid condition.
|
||||||
local ignore = false
|
local ignore = false
|
||||||
@@ -315,11 +307,13 @@ core.filter = async.throttle(function(self)
|
|||||||
-- Check fetching sources.
|
-- Check fetching sources.
|
||||||
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
|
||||||
if not s.incomplete and SOURCE_TIMEOUT > s:get_fetching_time() then
|
|
||||||
-- Reserve filter call for timeout.
|
-- Reserve filter call for timeout.
|
||||||
|
if not s.incomplete and SOURCE_TIMEOUT > s:get_fetching_time() then
|
||||||
self.filter.timeout = SOURCE_TIMEOUT - s:get_fetching_time()
|
self.filter.timeout = SOURCE_TIMEOUT - s:get_fetching_time()
|
||||||
self:filter()
|
self:filter()
|
||||||
break
|
if #sources == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
table.insert(sources, s)
|
table.insert(sources, s)
|
||||||
end
|
end
|
||||||
@@ -366,7 +360,7 @@ core.confirm = function(self, e, option, callback)
|
|||||||
table.insert(keys, keymap.backspace(ctx.cursor.character - misc.to_utfindex(ctx.cursor_line, e:get_offset())))
|
table.insert(keys, keymap.backspace(ctx.cursor.character - misc.to_utfindex(ctx.cursor_line, e:get_offset())))
|
||||||
table.insert(keys, e:get_word())
|
table.insert(keys, e:get_word())
|
||||||
table.insert(keys, keymap.undobreak())
|
table.insert(keys, keymap.undobreak())
|
||||||
feedkeys.call(table.concat(keys, ''), 'int')
|
feedkeys.call(table.concat(keys, ''), 'in')
|
||||||
end)
|
end)
|
||||||
feedkeys.call('', 'n', function()
|
feedkeys.call('', 'n', function()
|
||||||
local ctx = context.new()
|
local ctx = context.new()
|
||||||
|
|||||||
Reference in New Issue
Block a user