From dc6c6756158aaa9154309e8974b0d23f34a6b490 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 14 Sep 2024 15:18:44 +0200 Subject: [PATCH] fix: only set content on attach if it differs --- lua/codemp/buffers.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index bc8f761..5be3de7 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -109,8 +109,11 @@ local function attach(name, buffer, content, nowait) -- 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) + local current_content = utils.buffer.get_content(buffer) + if current_content ~= remote_content then + ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer) + utils.buffer.set_content(buffer, remote_content) + end end controller:callback(function (_controller) async:send() end)