Clear undo history if applying an undo/redo entry fails

A failed save means the object no longer matches the captured snapshot,
so the remaining entries can't be trusted either. Clear both stacks
instead of dropping just the failed entry.
This commit is contained in:
Dan Stillman 2026-06-05 15:18:58 -04:00 • committed by Tom Najdek
parent c30908db8c
commit 7a7d0bb587
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77

View file

@ -168,7 +168,10 @@ Zotero.UndoHistory = {
}
catch (e) {
Zotero.logError('UndoHistory: undo failed: ' + e);
// Entry is lost -- don't push to redo
// A failure means the object drifted out from under our snapshots,
// so the rest of the stack can't be trusted either. Discard history
// rather than risk applying stale values.
this.clear();
}
return true;
},
@ -202,7 +205,10 @@ Zotero.UndoHistory = {
}
catch (e) {
Zotero.logError('UndoHistory: redo failed: ' + e);
// Entry is lost -- don't push to undo
// A failure means the object drifted out from under our snapshots,
// so the rest of the stack can't be trusted either. Discard history
// rather than risk applying stale values.
this.clear();
}
return true;
},