Chromium Code Reviews| Index: components/omnibox/browser/omnibox_edit_model.cc |
| diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc |
| index b7728894ca48df22dba144ac54f73b0eedcbeef4..61e2052154f59483608105e522f49be3aa593e4a 100644 |
| --- a/components/omnibox/browser/omnibox_edit_model.cc |
| +++ b/components/omnibox/browser/omnibox_edit_model.cc |
| @@ -412,7 +412,7 @@ void OmniboxEditModel::StartAutocomplete( |
| bool entering_keyword_mode) { |
| size_t cursor_position; |
| const base::string16 input_text = MaybePrependKeyword(user_text_); |
| - if (inline_autocomplete_text_.empty()) { |
| + if (user_text_ == view_->GetText()) { |
|
Peter Kasting
2016/10/19 05:32:06
I spent some time tonight thinking about this and
|
| // Cursor position is equivalent to the current selection's end. |
| size_t start; |
| view_->GetSelectionBounds(&start, &cursor_position); |
| @@ -428,15 +428,17 @@ void OmniboxEditModel::StartAutocomplete( |
| cursor_position += input_text.length() - user_text_.length(); |
| } else { |
| // There are some cases where StartAutocomplete() may be called |
| - // with non-empty |inline_autocomplete_text_|. In such cases, we cannot |
| - // use the current selection, because it could result with the cursor |
| - // position past the last character from the user text. Instead, |
| - // we assume that the cursor is simply at the end of input. |
| - // One example is when user presses Ctrl key while having a highlighted |
| - // inline autocomplete text. |
| + // when |inline_autocomplete_text_| is nonempty, or when |
| + // view_->GetText().length() > input_text.length(). In such |
| + // cases, we cannot use the current selection, because it could |
| + // result with the cursor position past the last character from |
| + // the user text. Instead, we assume that the cursor is simply at |
| + // the end of input. One example is when user presses Ctrl key |
| + // while having a highlighted inline autocomplete text. |
| // TODO: Rethink how we are going to handle this case to avoid |
| - // inconsistent behavior when user presses Ctrl key. |
| - // See http://crbug.com/165961 and http://crbug.com/165968 for more details. |
| + // inconsistent behavior when user presses Ctrl key. See |
| + // http://crbug.com/165961 and http://crbug.com/165968 for more |
| + // details. |
| cursor_position = input_text.length(); |
| } |