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;