viewSelector: Make sure not to start searching when we only have whitespace
As this is thrown out before we actually query providers, we end up with a confusing screen that says "Searching..." that won't ever get results. https://bugzilla.gnome.org/show_bug.cgi?id=693458
This commit is contained in:
parent
569797d7c5
commit
65e4652142
@ -60,15 +60,6 @@ const SearchSystem = new Lang.Class({
|
|||||||
this.emit('search-updated', this._previousResults[i]);
|
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) {
|
updateSearchResults: function(terms) {
|
||||||
if (!terms)
|
if (!terms)
|
||||||
return;
|
return;
|
||||||
|
@ -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({
|
const ViewSelector = new Lang.Class({
|
||||||
Name: 'ViewSelector',
|
Name: 'ViewSelector',
|
||||||
@ -328,8 +336,10 @@ const ViewSelector = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onTextChanged: function (se, prop) {
|
_onTextChanged: function (se, prop) {
|
||||||
|
let terms = getTermsForSearchString(this._entry.get_text());
|
||||||
|
|
||||||
let searchPreviouslyActive = this._searchActive;
|
let searchPreviouslyActive = this._searchActive;
|
||||||
this._searchActive = this._entry.get_text() != '';
|
this._searchActive = (terms.length > 0);
|
||||||
|
|
||||||
let startSearch = this._searchActive && !searchPreviouslyActive;
|
let startSearch = this._searchActive && !searchPreviouslyActive;
|
||||||
if (startSearch)
|
if (startSearch)
|
||||||
@ -423,8 +433,10 @@ const ViewSelector = new Lang.Class({
|
|||||||
|
|
||||||
_doSearch: function () {
|
_doSearch: function () {
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
this._searchSystem.updateSearch(this._text.text);
|
|
||||||
|
|
||||||
|
let terms = getTermsForSearchString(this._entry.get_text());
|
||||||
|
|
||||||
|
this._searchSystem.updateSearchResults(terms);
|
||||||
this._showPage(this._searchPage);
|
this._showPage(this._searchPage);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user