diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index ffab65cda0..99974361e0 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -231,6 +231,14 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function() this._searchMode = this._itemGroup.isSearchMode(); + if (!this.selection.selectEventsSuppressed) { + var unsuppress = this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); + } + var savedSelection = this.saveSelection(); + var savedOpenState = this.saveOpenState(); + var savedFirstRow = this.saveFirstRow(); + var oldRows = this.rowCount; this._dataItems = []; this._searchItemIDs = {}; // items matching the search @@ -311,6 +319,15 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function() Zotero.UnresponsiveScriptIndicator.enable(); } + this.rememberOpenState(savedOpenState); + this.rememberFirstRow(savedFirstRow); + this.rememberSelection(savedSelection); + this.expandMatchParents(); + if (unsuppress) { + this._treebox.endUpdateBatch(); + this.selection.selectEventsSuppressed = false; + } + yield false; } @@ -399,6 +416,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) } this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); if ((action == 'remove' && !itemGroup.isLibrary(true)) || action == 'delete' || action == 'trash') { @@ -729,6 +747,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) this.rememberSelection(savedSelection); } + this._treebox.endUpdateBatch(); this.selection.selectEventsSuppressed = false; } @@ -1380,6 +1399,11 @@ Zotero.ItemTreeView.prototype.sort = function(itemID) } // Need to close all containers before sorting + if (!this.selection.selectEventsSuppressed) { + var unsuppress = this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); + } + var savedSelection = this.saveSelection(); var openItemIDs = this.saveOpenState(true); // Single-row sort @@ -1423,6 +1447,12 @@ Zotero.ItemTreeView.prototype.sort = function(itemID) this._refreshHashMap(); this.rememberOpenState(openItemIDs); + this.rememberSelection(savedSelection); + + if (unsuppress) { + this.selection.selectEventsSuppressed = false; + this._treebox.endUpdateBatch(); + } } //////////////////////////////////////////////////////////////////////////////// @@ -1638,7 +1668,7 @@ Zotero.ItemTreeView.prototype.deleteSelection = function (force) /* - * Set the tags filter on the view + * Set the search/tags filter on the view */ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { if (!this._treebox || !this._treebox.treeBody) { @@ -1647,9 +1677,7 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { } this.selection.selectEventsSuppressed = true; - var savedSelection = this.saveSelection(); - var savedOpenState = this.saveOpenState(); - var savedFirstRow = this.saveFirstRow(); + this._treebox.beginUpdateBatch(); switch (type) { case 'search': @@ -1666,11 +1694,7 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { this.sort(); - this.rememberOpenState(savedOpenState); - this.expandMatchParents(); - this.rememberFirstRow(savedFirstRow); - this.rememberSelection(savedSelection); - this._treebox.invalidate(); + this._treebox.endUpdateBatch(); this.selection.selectEventsSuppressed = false; //Zotero.debug('Running callbacks in itemTreeView.setFilter()', 4); @@ -1751,6 +1775,10 @@ Zotero.ItemTreeView.prototype.rememberSelection = function(selection) { this.selection.clearSelection(); + if (!this.selection.selectEventsSuppressed) { + var unsuppress = this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); + } for(var i=0; i < selection.length; i++) { if (this._itemRowMap[selection[i]] != null) { @@ -1777,6 +1805,10 @@ Zotero.ItemTreeView.prototype.rememberSelection = function(selection) } } } + if (unsuppress) { + this._treebox.endUpdateBatch(); + this.selection.selectEventsSuppressed = false; + } } @@ -1796,6 +1828,12 @@ Zotero.ItemTreeView.prototype.selectSearchMatches = function () { Zotero.ItemTreeView.prototype.saveOpenState = function(close) { var itemIDs = []; + if (close) { + if (!this.selection.selectEventsSuppressed) { + var unsuppress = this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); + } + } for (var i=0; i=0; i--) { this.toggleOpenState(rowsToOpen[i], true); } - this._treebox.endUpdateBatch(); this._refreshHashMap(); + if (unsuppress) { + this._treebox.endUpdateBatch(); + this.selection.selectEventsSuppressed = false; + } } @@ -1846,7 +1894,10 @@ Zotero.ItemTreeView.prototype.expandMatchParents = function () { hash[id] = true; } - this._treebox.beginUpdateBatch(); + if (!this.selection.selectEventsSuppressed) { + var unsuppress = this.selection.selectEventsSuppressed = true; + this._treebox.beginUpdateBatch(); + } for (var i=0; i