Clear undo/redo history when emptying the trash

This commit is contained in:
Tom Najdek 2026-06-09 17:34:59 +02:00
parent 189170f968
commit 8f5833061e
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77
2 changed files with 26 additions and 2 deletions

View file

@ -2562,6 +2562,7 @@ var ZoteroPane = new function () {
Zotero.hideZoteroPaneOverlays();
}
await Zotero.purgeDataObjects();
Zotero.UndoHistory.clear();
}
};

View file

@ -862,8 +862,31 @@ describe("ZoteroPane", function () {
assert.isTrue(item.deleted);
});
});
describe("#emptyTrash()", function () {
it("should clear the undo/redo history", async function () {
// Record an undo entry
Zotero.UndoHistory.clear();
var collection = await createDataObject('collection', { name: 'Original' });
collection.name = 'Renamed';
await collection.saveTx({ undoAction: 'undo-action-rename-collection' });
assert.isTrue(Zotero.UndoHistory.canUndo());
// Put something in the trash to empty
await createDataObject('item', { deleted: true });
await selectTrash(win);
var promise = waitForDialog();
await zp.emptyTrash();
await promise;
assert.isFalse(Zotero.UndoHistory.canUndo());
assert.isFalse(Zotero.UndoHistory.canRedo());
});
});
describe("#setVirtual()", function () {
var cv;