fix: correctly ack messages and tryrecv again if failed to apply

This commit is contained in:
frelodev 2024-10-26 21:55:23 +02:00
parent db4d71121d
commit 8266b94710

View file

@ -35,8 +35,10 @@ export async function apply_changes_to_buffer(path: string, controller: codemp.B
editBuilder editBuilder
.replace(range, event.change.content) .replace(range, event.change.content)
})) { })) {
vscode.window.showWarningMessage("Couldn't apply changes"); continue;
await resync(path, workspaceState.workspace, editor, 100); }
else{
controller.ack(event.version);
} }
locks.delete(path); locks.delete(path);
@ -130,7 +132,7 @@ export async function attach_to_remote_buffer(buffer_name: string, set_content?:
for (let change of event.contentChanges) { for (let change of event.contentChanges) {
if (skip_this !== undefined && change.text == skip_this) continue; if (skip_this !== undefined && change.text == skip_this) continue;
// LOGGER.info(`onDidChangeTextDocument(event: [${change.rangeOffset}, ${change.text}, ${change.rangeOffset + change.rangeLength}])`); // LOGGER.info(`onDidChangeTextDocument(event: [${change.rangeOffset}, ${change.text}, ${change.rangeOffset + change.rangeLength}])`);
buffer.send({ await buffer.send({
startIdx: change.rangeOffset, startIdx: change.rangeOffset,
endIdx: change.rangeOffset + change.rangeLength, endIdx: change.rangeOffset + change.rangeLength,
content: change.text content: change.text