diff --git a/js/ui/search.js b/js/ui/search.js index 96f92fa7c..dced01c04 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -60,15 +60,6 @@ const SearchSystem = new Lang.Class({ this.emit('search-updated', this._previousResults[i]); }, - updateSearch: function(searchString) { - searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, ''); - if (searchString == '') - return; - - let terms = searchString.split(/\s+/); - this.updateSearchResults(terms); - }, - updateSearchResults: function(terms) { if (!terms) return; diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index f2da6d183..c925cfdae 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -35,6 +35,14 @@ const FocusTrap = new Lang.Class({ } }); +function getTermsForSearchString(searchString) { + searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, ''); + if (searchString == '') + return []; + + let terms = searchString.split(/\s+/); + return terms; +} const ViewSelector = new Lang.Class({ Name: 'ViewSelector', @@ -328,8 +336,10 @@ const ViewSelector = new Lang.Class({ }, _onTextChanged: function (se, prop) { + let terms = getTermsForSearchString(this._entry.get_text()); + let searchPreviouslyActive = this._searchActive; - this._searchActive = this._entry.get_text() != ''; + this._searchActive = (terms.length > 0); let startSearch = this._searchActive && !searchPreviouslyActive; if (startSearch) @@ -423,8 +433,10 @@ const ViewSelector = new Lang.Class({ _doSearch: function () { this._searchTimeoutId = 0; - this._searchSystem.updateSearch(this._text.text); + let terms = getTermsForSearchString(this._entry.get_text()); + + this._searchSystem.updateSearchResults(terms); this._showPage(this._searchPage); },