fix: only set content on attach if it differs

This commit is contained in:
əlemi 2024-09-14 15:18:44 +02:00
parent 335ea236c4
commit dc6c675615
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -109,9 +109,12 @@ local function attach(name, buffer, content, nowait)
-- TODO this may happen too soon!! -- TODO this may happen too soon!!
local _ = controller:send(0, #remote_content, content) -- no need to await local _ = controller:send(0, #remote_content, content) -- no need to await
else else
local current_content = utils.buffer.get_content(buffer)
if current_content ~= remote_content then
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer) ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
utils.buffer.set_content(buffer, remote_content) utils.buffer.set_content(buffer, remote_content)
end end
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