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 8232aae8b8de4a26080de0f111343c22d7212a14..f811a5ed4fc557d2388aeccd0cd0174e2b140770 100644 |
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
@@ -883,9 +883,19 @@ void OmniboxEditModel::OnPopupDataChanged( |
bool call_controller_onchanged = true; |
inline_autocomplete_text_ = text; |
- if (view_->OnInlineAutocompleteTextMaybeChanged( |
- DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), |
- DisplayTextFromUserText(user_text_).length())) |
+ |
+ // Keyword search mode can be activated if the text before the inserted space |
+ // matches a keyword. The position of the cursor should be retained after |
+ // keyword mode is activated and it should be at the left of the 'search' |
+ // string. The window text should be set after stripping the keyword string |
+ // and the inserted space. And to set the caret at the left of the search |
+ // string to maintain the old position, it needs to be set to 0. |
Peter Kasting
2012/10/03 17:08:12
Thanks for adding comments here.
I wonder if we c
Joe Thomas
2012/10/03 18:04:59
This looks a lot better than the comments that I a
|
+ if (keyword_state_changed && KeywordIsSelected()) |
Peter Kasting
2012/10/03 17:08:12
Nit: {} needed on both arms, as one arm's body is
Joe Thomas
2012/10/03 18:04:59
Done.
|
+ view_->SetWindowTextAndCaretPos(DisplayTextFromUserText(user_text_), 0, |
+ false, false); |
+ else if (view_->OnInlineAutocompleteTextMaybeChanged( |
+ DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), |
+ DisplayTextFromUserText(user_text_).length())) |
call_controller_onchanged = false; |
// If |has_temporary_text_| is true, then we previously had a manual selection |