Bug 1719180 - Set restrictSource to the first restriction token, dropping support for combined tokens. r=mak

This bug was introduced because UnifiedComplete was only filtering tokens when the queryContext contained a restrictToken. UrlbarProvidersManager was only setting queryContext.restrictToken when a source restriction token was typed (i.e. not including $ and #). This meant that # and $ were never filtered from the search string. This patch now sets restrictToken to whatever the first token is, including # and $. This ensures UnifiedComplete will always filter tokens when a restriction token is typed.

Differential Revision: https://phabricator.services.mozilla.com/D119197
This commit is contained in:
Harry Twyford 2021-07-09 14:23:46 +00:00
Родитель 8a28a1ee1a
Коммит e44cbd69d2
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -653,7 +653,7 @@ function updateSourcesIfEmpty(context) {
return false;
}
let acceptedSources = [];
// There can be only one restrict token about sources.
// There can be only one restrict token per query.
let restrictToken = context.tokens.find(t =>
[
UrlbarTokenizer.TYPE.RESTRICT_HISTORY,
@ -661,9 +661,19 @@ function updateSourcesIfEmpty(context) {
UrlbarTokenizer.TYPE.RESTRICT_TAG,
UrlbarTokenizer.TYPE.RESTRICT_OPENPAGE,
UrlbarTokenizer.TYPE.RESTRICT_SEARCH,
UrlbarTokenizer.TYPE.RESTRICT_TITLE,
UrlbarTokenizer.TYPE.RESTRICT_URL,
].includes(t.type)
);
let restrictTokenType = restrictToken ? restrictToken.type : undefined;
// RESTRICT_TITLE and RESTRICT_URL do not affect query sources.
let restrictTokenType =
restrictToken &&
restrictToken.type != UrlbarTokenizer.TYPE.RESTRICT_TITLE &&
restrictToken.type != UrlbarTokenizer.TYPE.RESTRICT_URL
? restrictToken.type
: undefined;
for (let source of Object.values(UrlbarUtils.RESULT_SOURCE)) {
// Skip sources that the context doesn't care about.
if (context.sources && !context.sources.includes(source)) {