Commit b9940a8e authored by tby's avatar tby Committed by Commit Bot

Fix LauncherSearchProvider DCHECK.

The LSP can DCHECK when calculating query/title score matches, because
the query or title text can be empty. This is partly because the LSP
runs even on zero-state searches, and (perhaps) partly because files can
have no title.

This CL adds various checks to prevent calculating scores when we don't
have both a query and title. It also stops the LSP from running at all
on zero-state searches.

Bug: 1131358
Change-Id: I65c264def66e83f1c7fd47956eb0a9ddf59e099e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426088Reviewed-by: default avatarThanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Tony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811057}
parent 8643f33f
......@@ -38,6 +38,10 @@ constexpr double kPartialMatchPenaltyRate = 0.9;
double FuzzyMatchRelevance(const TokenizedString& title,
const TokenizedString& query) {
if (title.text().empty() || query.text().empty()) {
return kDefaultRelevance;
}
FuzzyTokenizedStringMatch match;
match.IsRelevant(query, title, kRelevanceThreshold, kUsePrefixOnly,
kUseWeightedRatio, kUseEditDistance,
......@@ -74,6 +78,10 @@ void LauncherSearchProvider::Start(const base::string16& query) {
// Clear previously added search results.
ClearResults();
// LauncherSearchProvider only handles query searches.
if (query.empty())
return;
last_tokenized_query_.emplace(query, TokenizedString::Mode::kWords);
DelayQuery(base::Bind(&LauncherSearchProvider::StartInternal,
weak_ptr_factory_.GetWeakPtr(), query));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment