File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,16 @@ local function attach(name, force)
5454 -- hook clientbound callbacks
5555 async .handler (name , controller , function (event )
5656 ticks [buffer ] = vim .api .nvim_buf_get_changedtick (buffer )
57- print (" ~~ applying change ~~ " .. event .first .. " .." .. event .last .. " ::" .. event .content )
57+ if event .hash ~= nil then
58+ if utils .hash (utils .buffer .get_content (buffer )) ~= event .hash then
59+ -- OUT OF SYNC!
60+ -- TODO this may be destructive! we should probably prompt the user before doing this
61+ print (" /!\\ out of sync, resynching..." )
62+ utils .buffer .set_content (buffer , controller :content ())
63+ return
64+ end
65+ end
66+ -- print(" ~~ applying change ~~ " .. event.first .. ".." .. event.last .. "::" .. event.content)
5867 utils .buffer .set_content (buffer , event .content , event .first , event .last )
5968 end , 20 ) -- wait 20ms before polling again because it overwhelms libuv?
6069
You can’t perform that action at this time.
0 commit comments