Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 98463012: Infinite Suggest for mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments, bit rewrite Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9440b007f86c428caa4e86e9d5e3253cd2ed9ec5 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -109,13 +109,21 @@ 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) {
+ size_t query_length = query_string.length();
+ size_t contents_index = query_length - match_contents.length();
+ if ((query_string.compare(0, input_text.length(), input_text) == 0) &&
+ (query_string.compare(
+ contents_index, query_length, match_contents) == 0))
Scott Hess - ex-Googler 2013/12/16 22:22:05 {} isn't optional if the if() condition causes lin
Anuj 2013/12/19 05:36:13 Done.
Scott Hess - ex-Googler 2013/12/19 20:15:02 Still don't see the {}, here, did you need to re-u
+ lookup_text = input_text.substr(contents_index);
+ }
// 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 +137,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));

Powered by Google App Engine
This is Rietveld 408576698