From 8f5833061e23757b7d36fd0e158e0bef0d93b5ac Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Tue, 9 Jun 2026 17:34:59 +0200 Subject: [PATCH] Clear undo/redo history when emptying the trash --- chrome/content/zotero/zoteroPane.js | 1 + test/tests/zoteroPaneTest.js | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 027d0feef0..2a1b1adf27 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2562,6 +2562,7 @@ var ZoteroPane = new function () { Zotero.hideZoteroPaneOverlays(); } await Zotero.purgeDataObjects(); + Zotero.UndoHistory.clear(); } }; diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index b4fe9b147e..6422068855 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -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;