Skip to content

Commit

Permalink
fix: schedule cmdline item building
Browse files Browse the repository at this point in the history
Closes #1038
  • Loading branch information
Saghen committed Jan 19, 2025
1 parent 3f9b798 commit f74f249
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/blink/cmp/lib/async.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--- @field cancel fun(self: blink.cmp.Task)
--- @field map fun(self: blink.cmp.Task, fn: fun(result: any): blink.cmp.Task | any): blink.cmp.Task
--- @field catch fun(self: blink.cmp.Task, fn: fun(err: any): blink.cmp.Task | any): blink.cmp.Task
--- @field schedule fun(self: blink.cmp.Task): blink.cmp.Task
---
--- @field on_completion fun(self: blink.cmp.Task, cb: fun(result: any))
--- @field on_failure fun(self: blink.cmp.Task, cb: fun(err: any))
Expand Down Expand Up @@ -133,6 +134,14 @@ function task:catch(fn)
return chained_task
end

function task:schedule()
return self:map(function(value)
return task.new(function(resolve)
vim.schedule(function() resolve(value) end)
end)
end)
end

--- events

function task:on_completion(cb)
Expand Down
1 change: 1 addition & 0 deletions lua/blink/cmp/sources/cmdline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function cmdline:get_completions(context, callback)

return completions
end)
:schedule()
:map(function(completions)
local items = {}
for _, completion in ipairs(completions) do
Expand Down

0 comments on commit f74f249

Please sign in to comment.