| Index: chrome/browser/autocomplete/search_provider.cc
|
| diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
|
| index 143e4661205fe63682dea1a77529a34811f1e0dd..d53fb405dcfdba11bcae8897473c8758ac2b1ecd 100644
|
| --- a/chrome/browser/autocomplete/search_provider.cc
|
| +++ b/chrome/browser/autocomplete/search_provider.cc
|
| @@ -109,13 +109,19 @@ void SetAndClassifyMatchContents(const base::string16& query_string,
|
| const base::string16& match_contents,
|
| AutocompleteMatch* match) {
|
| match->contents = match_contents.empty() ? query_string : match_contents;
|
| -
|
| + base::string16 lookup_text = input_text;
|
| + if (match->type == AutocompleteMatchType::SEARCH_SUGGEST_INFINITE) {
|
| + const base::string16 prefix =
|
| + query_string.substr(0, query_string.rfind(match_contents));
|
| + lookup_text = input_text.find(prefix) == 0 ?
|
| + input_text.substr(prefix.length()) : input_text;
|
| + }
|
| // We do intra-string highlighting for suggestions - the suggested segment
|
| // will be highlighted, e.g. for input_text = "you" the suggestion may be
|
| // "youtube", so we'll bold the "tube" section: you*tube*.
|
| - if (input_text != match_contents) {
|
| - size_t input_position = match->contents.find(input_text);
|
| - if (input_position == base::string16::npos) {
|
| + if (lookup_text != match_contents) {
|
| + size_t lookup_position = match->contents.find(lookup_text);
|
| + if (lookup_position == base::string16::npos) {
|
| // The input text is not a substring of the query string, e.g. input
|
| // text is "slasdot" and the query string is "slashdot", so we bold the
|
| // whole thing.
|
| @@ -129,13 +135,13 @@ void SetAndClassifyMatchContents(const base::string16& query_string,
|
| // short as a single character highlighted in a query suggestion result,
|
| // e.g. for input text "s" and query string "southwest airlines", it
|
| // looks odd if both the first and last s are highlighted.
|
| - if (input_position != 0) {
|
| + if (lookup_position != 0) {
|
| match->contents_class.push_back(ACMatchClassification(
|
| 0, ACMatchClassification::MATCH));
|
| }
|
| match->contents_class.push_back(
|
| - ACMatchClassification(input_position, ACMatchClassification::NONE));
|
| - size_t next_fragment_position = input_position + input_text.length();
|
| + ACMatchClassification(lookup_position, ACMatchClassification::NONE));
|
| + size_t next_fragment_position = lookup_position + lookup_text.length();
|
| if (next_fragment_position < query_string.length()) {
|
| match->contents_class.push_back(ACMatchClassification(
|
| next_fragment_position, ACMatchClassification::MATCH));
|
|
|