fix: wait for initial buffer content sync

This commit is contained in:
əlemi 2024-09-06 18:24:57 +02:00
parent 30cf1e1554
commit 68362f1f08
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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