From 3ee546be4dc3626bdf66d023393b189d19539b67 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 26 Sep 2024 17:42:48 +0200 Subject: [PATCH] fix: lock for receiving changes must never have more than 1 callback consuming --- lua/codemp/buffers.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index 6575f14..922ed28 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -112,7 +112,10 @@ local function attach(name, opts) end, }) + local lock = false local async = vim.loop.new_async(vim.schedule_wrap(function () + if lock then return end + lock = true while true do local event = controller:try_recv():await() if event == nil then break end @@ -132,6 +135,7 @@ local function attach(name, opts) end end end + lock = false end)) local remote_content = controller:content():await()