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

Unified Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 12039053: Fix cursor position for default provider searches in keyword mode. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Final set of fixes, including two unit test cases, previously not uploaded. Created 7 years, 10 months 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
« no previous file with comments | « chrome/browser/autocomplete/search_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/omnibox/omnibox_edit_model.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 8e16c6e8012ed518b3c2330e3acb1ea3702bfcce..47df8c00fbb496a6bb98eae7dcd9ab27f8217312 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -465,6 +465,12 @@ void OmniboxEditModel::StartAutocomplete(
// Cursor position is equivalent to the current selection's end.
size_t start;
view_->GetSelectionBounds(&start, &cursor_position);
+ // Adjust cursor position taking into account possible keyword in the
+ // user text. We rely on DisplayTextFromUserText method which is consistent
sky 2013/02/05 20:54:08 Add () after comments referencing functions, eg Di
Bart N. 2013/02/05 21:18:24 Done.
+ // with keyword extraction done in KeywordProvider/SearchProvider.
+ const size_t cursor_offset =
+ user_text_.length() - DisplayTextFromUserText(user_text_).length();
+ cursor_position += cursor_offset;
} else {
// There are some cases where StartAutocomplete() may be called
// with non-empty |inline_autocomplete_text_|. In such cases, we cannot
« no previous file with comments | « chrome/browser/autocomplete/search_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698