mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
fix: while attaching, set content later
This commit is contained in:
parent
46de8c5661
commit
30cf1e1554
1 changed files with 7 additions and 6 deletions
|
@ -32,10 +32,6 @@ local function attach(name, buffer, content)
|
||||||
buffer_id_map[name] = buffer
|
buffer_id_map[name] = buffer
|
||||||
ticks[buffer] = 0
|
ticks[buffer] = 0
|
||||||
|
|
||||||
if content ~= nil then
|
|
||||||
local _ = controller:send(0, 0, content) -- no need to await
|
|
||||||
end
|
|
||||||
|
|
||||||
-- hook serverbound callbacks
|
-- hook serverbound callbacks
|
||||||
-- TODO breaks when deleting whole lines at buffer end
|
-- TODO breaks when deleting whole lines at buffer end
|
||||||
vim.api.nvim_buf_attach(buffer, false, {
|
vim.api.nvim_buf_attach(buffer, false, {
|
||||||
|
@ -84,8 +80,13 @@ local function attach(name, buffer, content)
|
||||||
end))
|
end))
|
||||||
|
|
||||||
local remote_content = controller:content():await()
|
local remote_content = controller:content():await()
|
||||||
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
|
if content ~= nil then
|
||||||
utils.buffer.set_content(buffer, remote_content)
|
-- TODO this may happen too soon!!
|
||||||
|
local _ = controller:send(0, #remote_content, content) -- no need to await
|
||||||
|
else
|
||||||
|
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
|
||||||
|
utils.buffer.set_content(buffer, remote_content)
|
||||||
|
end
|
||||||
|
|
||||||
controller:callback(function (_controller) async:send() end)
|
controller:callback(function (_controller) async:send() end)
|
||||||
vim.defer_fn(function() async:send() end, 500) -- force a try_recv after 500ms
|
vim.defer_fn(function() async:send() end, 500) -- force a try_recv after 500ms
|
||||||
|
|
Loading…
Reference in a new issue