feat: now sync only sets buffer if necessary

does one extra get_content but worth it because we dont mess with undo
history
This commit is contained in:
əlemi 2024-09-09 05:14:19 +02:00
parent 087df96566
commit b824b87505
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -126,9 +126,15 @@ local function sync(buffer)
if name ~= nil then
local controller = session.workspace:get_buffer(name)
if controller ~= nil then
local real_content = controller:content():await()
local my_content = utils.buffer.get_content(buffer)
if real_content ~= my_content then
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
utils.buffer.set_content(buffer, controller:content():await())
print(" :: synched buffer " .. name)
utils.buffer.set_content(buffer, real_content)
print(" !! re-synched buffer " .. name)
else
print(" :: buffer " .. name .. " is in sync")
end
return
end
end