Add THROTTLE_TIME constant

This commit is contained in:
hrsh7th
2021-09-08 13:07:30 +09:00
parent 5551dfab17
commit fa031530ed

View File

@@ -15,6 +15,7 @@ local types = require('cmp.types')
local core = {} local core = {}
core.SOURCE_TIMEOUT = 500 core.SOURCE_TIMEOUT = 500
core.THROTTLE_TIME = 80
---Suspending state. ---Suspending state.
core.suspending = false core.suspending = false
@@ -202,7 +203,7 @@ core.on_change = function(event)
if vim.tbl_contains(config.get().completion.autocomplete or {}, event) then if vim.tbl_contains(config.get().completion.autocomplete or {}, event) then
core.complete(ctx) core.complete(ctx)
else else
core.filter.timeout = 50 core.filter.timeout = core.THROTTLE_TIME
core.filter() core.filter()
end end
else else
@@ -239,7 +240,7 @@ core.complete = function(ctx)
if new:changed(new.prev_context) then if new:changed(new.prev_context) then
core.complete(new) core.complete(new)
else else
core.filter.timeout = 50 core.filter.timeout = core.THROTTLE_TIME
core.filter() core.filter()
end end
end end
@@ -247,7 +248,7 @@ core.complete = function(ctx)
s:complete(ctx, callback) s:complete(ctx, callback)
end end
core.filter.timeout = ctx.pumvisible and 50 or 0 core.filter.timeout = ctx.pumvisible and core.THROTTLE_TIME or 0
core.filter() core.filter()
end end
@@ -273,7 +274,7 @@ core.filter = async.throttle(function()
core.menu:update(ctx, sources) core.menu:update(ctx, sources)
core.ghost_text(core.menu:get_first_entry()) core.ghost_text(core.menu:get_first_entry())
end, 50) end, core.THROTTLE_TIME)
---Confirm completion. ---Confirm completion.
---@param e cmp.Entry ---@param e cmp.Entry