mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-24 16:34:48 +01:00
fix: check hash before applying changes
Some checks failed
test / build-test (push) Has been cancelled
publish / build (arm64, arm64, macos-latest, darwin) (push) Has been cancelled
publish / build (x64, x64, ubuntu-latest, linux) (push) Has been cancelled
publish / build (x64, x64, windows-latest, win32) (push) Has been cancelled
publish / publish (push) Has been cancelled
Some checks failed
test / build-test (push) Has been cancelled
publish / build (arm64, arm64, macos-latest, darwin) (push) Has been cancelled
publish / build (x64, x64, ubuntu-latest, linux) (push) Has been cancelled
publish / build (x64, x64, windows-latest, win32) (push) Has been cancelled
publish / publish (push) Has been cancelled
This commit is contained in:
parent
aca566ab8e
commit
c0682ec0ec
1 changed files with 11 additions and 9 deletions
|
@ -30,15 +30,6 @@ export async function apply_changes_to_buffer(path: string, controller: codemp.B
|
||||||
editor.document.positionAt(event.change.endIdx)
|
editor.document.positionAt(event.change.endIdx)
|
||||||
)
|
)
|
||||||
|
|
||||||
locks.set(path, event.change.content);
|
|
||||||
let success = await editor.edit(editBuilder => {
|
|
||||||
editBuilder
|
|
||||||
.replace(range, event.change.content)
|
|
||||||
});
|
|
||||||
if(success) controller.ack(event.version);
|
|
||||||
locks.delete(path);
|
|
||||||
if(!success) continue;
|
|
||||||
|
|
||||||
if (event.hash !== undefined) {
|
if (event.hash !== undefined) {
|
||||||
if (codemp.hash(editor.document.getText()) !== event.hash) {
|
if (codemp.hash(editor.document.getText()) !== event.hash) {
|
||||||
if (autoResync) {
|
if (autoResync) {
|
||||||
|
@ -56,6 +47,17 @@ export async function apply_changes_to_buffer(path: string, controller: codemp.B
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locks.set(path, event.change.content);
|
||||||
|
let success = await editor.edit(editBuilder => {
|
||||||
|
editBuilder
|
||||||
|
.replace(range, event.change.content)
|
||||||
|
});
|
||||||
|
if(success) controller.ack(event.version);
|
||||||
|
locks.delete(path);
|
||||||
|
if(!success) continue;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
singles.set(path, false);
|
singles.set(path, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue