feat: clear cursor on user leave, redraw windows

This commit is contained in:
əlemi 2024-08-17 03:28:34 +02:00
parent 733dca385b
commit 625bcb504d
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -56,6 +56,9 @@ local function register_cursor_handler(controller)
event.finish event.finish
) )
end end
if old_buffer ~= buffer then
window.update() -- redraw user positions
end
end end
end)) end))
controller:callback(function (_controller) async:send() end) controller:callback(function (_controller) async:send() end)
@ -66,9 +69,18 @@ local function join(workspace)
register_cursor_callback(ws.cursor) register_cursor_callback(ws.cursor)
register_cursor_handler(ws.cursor) register_cursor_handler(ws.cursor)
-- ws:callback(function (_ev) ws:callback(function (event)
-- vim.schedule(function() window.update() end) if event.type == "leave" then
-- end) if buffers.users[event.value] ~= nil then
vim.schedule(function ()
vim.api.nvim_buf_clear_namespace(buffers.users[event.value], user_hl[event.value].ns, 0, -1)
buffers.users[event.value] = nil
user_hl[event.value] = nil
end)
end
end
vim.schedule(function() window.update() end)
end)
window.update() window.update()
end end