Skip to content

Commit

Permalink
perf(accept): schedule fuzzy.access using uv.new_work
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanboca committed Dec 13, 2024
1 parent 7868d47 commit 92112fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lua/blink/cmp/completion/accept/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ local function accept(ctx, item, callback)
end

-- Notify the rust module that the item was accessed
-- TODO: why is this so slow? (10ms)
vim.schedule(function() require('blink.cmp.fuzzy').access(item) end)
require('blink.cmp.fuzzy').access(item)
end)
end)
:catch(function(err) vim.notify(err, vim.log.levels.ERROR) end)
Expand Down
6 changes: 5 additions & 1 deletion lua/blink/cmp/fuzzy/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ end
---@param item blink.cmp.CompletionItem
function fuzzy.access(item)
fuzzy.init_db()
fuzzy.rust.access(item)

-- writing to the db takes ~10ms, so schedule writes in another thread
vim.uv
.new_work(function(itm) require('blink.cmp.fuzzy.rust').access(vim.mpack.decode(itm)) end, function() end)
:queue(vim.mpack.encode(item))
end

---@param lines string
Expand Down

0 comments on commit 92112fe

Please sign in to comment.