search: Change order of duplicate search check

Checks for a duplicate search before setting the current search
to true and before cancelling the current search. This ensures that
if a duplicate search occurs while the previous search is still active,
the duplicate search will not incorrectly cancel or change the state
of the previous search.
This commit is contained in:
Patrick Ward 2014-09-30 17:47:07 -07:00 committed by Jasper St. Pierre
parent fc3ad390b7
commit 72b0a3d78f

View File

@ -498,6 +498,15 @@ const SearchResults = new Lang.Class({
}, },
setTerms: function(terms) { setTerms: function(terms) {
// Check for the case of making a duplicate previous search before
// setting state of the current search or cancelling the search.
// This will prevent incorrect state being as a result of a duplicate
// search while the previous search is still active.
let searchString = terms.join(' ');
let previousSearchString = this._terms.join(' ');
if (searchString == previousSearchString)
return;
this._startingSearch = true; this._startingSearch = true;
this._cancellable.cancel(); this._cancellable.cancel();
@ -508,11 +517,6 @@ const SearchResults = new Lang.Class({
return; return;
} }
let searchString = terms.join(' ');
let previousSearchString = this._terms.join(' ');
if (searchString == previousSearchString)
return;
let isSubSearch = false; let isSubSearch = false;
if (this._terms.length > 0) if (this._terms.length > 0)
isSubSearch = searchString.indexOf(previousSearchString) == 0; isSubSearch = searchString.indexOf(previousSearchString) == 0;