mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 23:44:55 +01:00
fix: compare hash before change
this anticipates a fix that is going to land in 0.8.3
This commit is contained in:
parent
d15336cb4a
commit
1543625bd5
1 changed files with 24 additions and 26 deletions
|
@ -136,17 +136,9 @@ local function attach(name, opts)
|
||||||
while true do
|
while true do
|
||||||
local event = controller:try_recv():await()
|
local event = controller:try_recv():await()
|
||||||
if event == nil then break end
|
if event == nil then break end
|
||||||
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
|
|
||||||
CODEMP.ignore_following_action = true
|
|
||||||
if CODEMP.config.debug then
|
|
||||||
print(" ~~ applying change ~~ " .. event.change.start_idx .. ".." .. event.change.end_idx .. "::[" .. event.change.content .. "]")
|
|
||||||
end
|
|
||||||
utils.buffer.set_content(buffer, event.change.content, event.change.start_idx, event.change.end_idx)
|
|
||||||
controller:ack(event.version)
|
|
||||||
|
|
||||||
-- error detection
|
-- error detection
|
||||||
if event.hash ~= nil then
|
if event.hash ~= nil and CODEMP.native.hash(utils.buffer.get_content(buffer)) ~= event.hash then
|
||||||
if CODEMP.native.hash(utils.buffer.get_content(buffer)) ~= event.hash then
|
|
||||||
if CODEMP.config.auto_sync then
|
if CODEMP.config.auto_sync then
|
||||||
print(" /!\\ out of sync, resynching...")
|
print(" /!\\ out of sync, resynching...")
|
||||||
utils.buffer.set_content(buffer, controller:content():await())
|
utils.buffer.set_content(buffer, controller:content():await())
|
||||||
|
@ -155,7 +147,6 @@ local function attach(name, opts)
|
||||||
{ "sync", "detach" },
|
{ "sync", "detach" },
|
||||||
{ prompt = "out of sync! force resync or detach?" },
|
{ prompt = "out of sync! force resync or detach?" },
|
||||||
function (choice)
|
function (choice)
|
||||||
if not choice then return end
|
|
||||||
if choice == "sync" then
|
if choice == "sync" then
|
||||||
utils.buffer.set_content(buffer, controller:content():await())
|
utils.buffer.set_content(buffer, controller:content():await())
|
||||||
end
|
end
|
||||||
|
@ -168,7 +159,14 @@ local function attach(name, opts)
|
||||||
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ticks[buffer] = vim.api.nvim_buf_get_changedtick(buffer)
|
||||||
|
CODEMP.ignore_following_action = true
|
||||||
|
if CODEMP.config.debug then
|
||||||
|
print(" ~~ applying change ~~ " .. event.change.start_idx .. ".." .. event.change.end_idx .. "::[" .. event.change.content .. "]")
|
||||||
end
|
end
|
||||||
|
utils.buffer.set_content(buffer, event.change.content, event.change.start_idx, event.change.end_idx)
|
||||||
|
controller:ack(event.version)
|
||||||
end
|
end
|
||||||
lock = false
|
lock = false
|
||||||
end))
|
end))
|
||||||
|
|
Loading…
Reference in a new issue