From 68362f1f08ccda77ad960297e11f4c936efa76d4 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 6 Sep 2024 18:24:57 +0200 Subject: [PATCH] fix: wait for initial buffer content sync --- lua/codemp/buffers.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index f00638d..aa652a5 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -12,8 +12,9 @@ local ticks = {} ---@param name string name of buffer to attach to ---@param buffer? integer if provided, use given buffer (will clear content) ---@param content? string if provided, set this content after attaching +---@param nowait? boolean skip waiting for initial content sync ---@return BufferController -local function attach(name, buffer, content) +local function attach(name, buffer, content, nowait) if buffer_id_map[name] ~= nil then error("already attached to buffer " .. name) end @@ -25,6 +26,9 @@ local function attach(name, buffer, content) vim.api.nvim_set_current_buf(buffer) end local controller = session.workspace:attach_buffer(name):await() + if not nowait then + controller:poll():await() -- wait for current state to get synched + end -- TODO map name to uuid