fix: run poller callbacks on main thread

This commit is contained in:
əlemi 2024-09-17 01:45:54 +02:00
parent b80d1898be
commit ecf58046b5
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 8 deletions

View file

@ -22,7 +22,7 @@ local function async_poller(generator, callback)
timer:start(500, 500, function()
if promise == nil then promise = generator() end
if promise.ready then
callback(promise:await())
vim.schedule(function() callback(promise:await()) end)
promise = nil
end
end)

View file

@ -117,12 +117,10 @@ local function join(workspace)
function(event)
if event.type == "leave" then
if buffers.users[event.value] ~= nil then
vim.schedule(function ()
local buf_name = buffers.users[event.value]
vim.api.nvim_buf_clear_namespace(buffers.map_rev[buf_name], user_hl[event.value].ns, 0, -1)
buffers.users[event.value] = nil
user_hl[event.value] = nil
end)
end
elseif event.type == "join" then
buffers.users[event.value] = ""
@ -132,7 +130,7 @@ local function join(workspace)
pos = { 0, 0 },
}
end
vim.schedule(function() require('codemp.window').update() end)
require('codemp.window').update()
end
)