Pad: Don't create no-op revisions

This commit is contained in:
Richard Hansen 2021-12-11 20:03:35 -05:00
parent 56b7671422
commit a370cfa5c6
6 changed files with 18 additions and 12 deletions

View file

@ -207,8 +207,10 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
});
} else if (msg.type === 'ACCEPT_COMMIT') {
serverMessageTaskQueue.enqueue(() => {
const newRev = msg.newRev;
if (newRev !== (rev + 1)) {
const {newRev} = msg;
// newRev will equal rev if the changeset has no net effect (identity changeset, or removing
// and re-adding the same characters with the same attributes).
if (![rev, rev + 1].includes(newRev)) {
window.console.warn(`bad message revision on ACCEPT_COMMIT: ${newRev} not ${rev + 1}`);
// setChannelState("DISCONNECTED", "badmessage_acceptcommit");
return;