fix: invoke attach callback on main thread

This commit is contained in:
əlemi 2024-09-27 23:35:26 +02:00
parent 14286f1699
commit d0d1fb73ae
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -57,7 +57,9 @@ local function attach(name, opts)
vim.api.nvim_set_option_value('fileformat', 'unix', { buf = buffer })
vim.api.nvim_buf_set_name(buffer, name)
CODEMP.workspace:attach(name):and_then(function (controller)
vim.schedule(function()
-- TODO disgusting! but poll blocks forever on empty buffers...
if not opts.nowait then
local promise = controller:poll()
@ -189,6 +191,7 @@ local function attach(name, opts)
print(" ++ attached to buffer " .. name)
require('codemp.window').update()
end)
end)
end
---@param buffer? integer if provided, sync given buffer id, otherwise sync current buf