Chromium Code Reviews| Index: chrome/browser/history/url_index_private_data.cc |
| diff --git a/chrome/browser/history/url_index_private_data.cc b/chrome/browser/history/url_index_private_data.cc |
| index ca38009bfd354a001da8f22fe28a903349a28754..c0e772dd7eb77336c8b53601b947da9de341428c 100644 |
| --- a/chrome/browser/history/url_index_private_data.cc |
| +++ b/chrome/browser/history/url_index_private_data.cc |
| @@ -9,6 +9,7 @@ |
| #include <iterator> |
| #include <limits> |
| #include <numeric> |
| +#include <string> |
| #include <vector> |
| #include "base/basictypes.h" |
| @@ -78,7 +79,18 @@ URLIndexPrivateData::URLIndexPrivateData() |
| ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms( |
| const string16& search_string, |
| + size_t cursor_position, |
| BookmarkService* bookmark_service) { |
| + // If cursor position is set and useful (not at either end of the string), |
| + // allow the search string to be broken at cursor position. We do this |
| + // by pretending there's a space where the cursor is. |
| + // TODO(figure out highlighting). |
| + const string16& search_string_with_cursor = |
| + ((cursor_position != string16::npos) && |
| + (cursor_position < search_string.length()) && |
| + (cursor_position > 0)) ? |
| + search_string.substr(0, cursor_position) + kWhitespaceUTF16 + |
|
Peter Kasting
2013/01/04 23:47:39
This doesn't insert a space, it inserts a whole st
Mark P
2013/01/09 19:51:53
Done.
|
| + search_string.substr(cursor_position) : search_string; |
| pre_filter_item_count_ = 0; |
| post_filter_item_count_ = 0; |
| post_scoring_item_count_ = 0; |
| @@ -86,7 +98,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms( |
| // the index we need individual, lower-cased words, ignoring escapings. For |
| // the final filtering we need whitespace separated substrings possibly |
| // containing escaped characters. |
| - string16 lower_raw_string(base::i18n::ToLower(search_string)); |
| + string16 lower_raw_string(base::i18n::ToLower(search_string_with_cursor)); |
| string16 lower_unescaped_string = |
| net::UnescapeURLComponent(lower_raw_string, |
| net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); |