[gnome-shell] search: Simplify and correct behavior for substring searches



commit b292bba092829cf76f79521a8958cc0b14d4c886
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 15 23:10:42 2013 -0500

    search: Simplify and correct behavior for substring searches
    
    Early on, search was based on a list of terms, which was like a set
    of tags, in that terms were OR'd, and that order didn't matter. As
    such, modifying any one of the terms wouldn't produce new results.
    Nowadays, providers take the order into account, so a substring
    should only be the case if new terms are added to the end.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693935

 js/ui/search.js |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index dced01c..c4eb10c 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -64,15 +64,12 @@ const SearchSystem = new Lang.Class({
         if (!terms)
             return;
 
-        let isSubSearch = terms.length == this._previousTerms.length;
-        if (isSubSearch) {
-            for (let i = 0; i < terms.length; i++) {
-                if (terms[i].indexOf(this._previousTerms[i]) != 0) {
-                    isSubSearch = false;
-                    break;
-                }
-            }
-        }
+        let searchString = terms.join(' ');
+        let previousSearchString = this._previousTerms.join(' ');
+
+        let isSubSearch = false;
+        if (this._previousTerms.length > 0)
+            isSubSearch = searchString.indexOf(previousSearchString) == 0;
 
         let previousResultsArr = this._previousResults;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]