Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(#725): inherit package.cpath in worker thread #726

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lua/blink/cmp/fuzzy/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ function fuzzy.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))
.new_work(function(itm, cpath)
package.cpath = cpath
require('blink.cmp.fuzzy.rust').access(vim.mpack.decode(itm))
end, function() end)
:queue(vim.mpack.encode(item), package.cpath)
end

---@param lines string
Expand Down
7 changes: 5 additions & 2 deletions lua/blink/cmp/sources/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ local function run_sync(buf_text, callback) callback(words_to_items(require('bli
local function run_async(buf_text, callback)
local worker = uv.new_work(
-- must use ffi directly since the normal one requires the config which isnt present
function(items) return table.concat(require('blink.cmp.fuzzy.rust').get_words(items), '\n') end,
function(items, cpath)
package.cpath = cpath
return table.concat(require('blink.cmp.fuzzy.rust').get_words(items), '\n')
end,
function(words)
local items = words_to_items(vim.split(words, '\n'))
vim.schedule(function() callback(items) end)
end
)
worker:queue(buf_text)
worker:queue(buf_text, package.cpath)
end

--- @class blink.cmp.BufferOpts
Expand Down