зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1187753 - Autocomplete popup displays wrong message when typing only a search keyword. r=adw
--HG-- extra : commitid : 5SWM67W3LKr
This commit is contained in:
Родитель
3d559535cd
Коммит
fc4223158d
|
@ -78,6 +78,9 @@ const MINIMUM_LOCAL_MATCHES = 5;
|
|||
// don't need to be exhaustive here, so allow dashes anywhere.
|
||||
const REGEXP_SINGLEWORD_HOST = new RegExp("^[a-z0-9-]+$", "i");
|
||||
|
||||
// Regex used to match one or more whitespace.
|
||||
const REGEXP_SPACES = /\s+/;
|
||||
|
||||
// Sqlite result row index constants.
|
||||
const QUERYINDEX_QUERYTYPE = 0;
|
||||
const QUERYINDEX_URL = 1;
|
||||
|
@ -517,7 +520,7 @@ function fixupSearchText(spec)
|
|||
* an empty array then.
|
||||
*/
|
||||
function getUnfilteredSearchTokens(searchString)
|
||||
searchString.length ? searchString.split(" ") : [];
|
||||
searchString.length ? searchString.split(REGEXP_SPACES) : [];
|
||||
|
||||
/**
|
||||
* Strip prefixes from the URI that we don't care about for searching.
|
||||
|
@ -977,7 +980,7 @@ Search.prototype = {
|
|||
if (searchString.length < 2)
|
||||
return true;
|
||||
|
||||
let tokens = searchString.split(/\s/);
|
||||
let tokens = searchString.split(REGEXP_SPACES);
|
||||
|
||||
// The first token may be a whitelisted host.
|
||||
if (REGEXP_SINGLEWORD_HOST.test(tokens[0]) &&
|
||||
|
@ -1105,7 +1108,7 @@ Search.prototype = {
|
|||
},
|
||||
|
||||
_matchSearchEngineAlias: function* () {
|
||||
if (this._searchTokens.length < 2)
|
||||
if (this._searchTokens.length < 1)
|
||||
return false;
|
||||
|
||||
let alias = this._searchTokens[0];
|
||||
|
@ -1589,7 +1592,7 @@ Search.prototype = {
|
|||
// This may confuse completeDefaultIndex cause the AUTOCOMPLETE_MATCH
|
||||
// tokenizer ends up trimming the search string and returning a value
|
||||
// that doesn't match it, or is even shorter.
|
||||
if (/\s/.test(this._originalSearchString))
|
||||
if (REGEXP_SPACES.test(this._originalSearchString))
|
||||
return false;
|
||||
|
||||
if (this._searchString.length == 0)
|
||||
|
|
|
@ -359,7 +359,7 @@ function makeSearchMatch(input, extra = {}) {
|
|||
let params = {
|
||||
engineName: extra.engineName || "MozSearch",
|
||||
input,
|
||||
searchQuery: extra.searchQuery || input,
|
||||
searchQuery: "searchQuery" in extra ? extra.searchQuery : input,
|
||||
alias: extra.alias, // may be undefined which is expected.
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -12,7 +12,13 @@ add_task(function*() {
|
|||
yield check_autocomplete({
|
||||
search: "doit",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit") ]
|
||||
matches: [ makeSearchMatch("doit", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit" }) ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
search: "doit ",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit ", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit" }) ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
|
|
Загрузка…
Ссылка в новой задаче