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

Unified Diff: components/omnibox/browser/omnibox_edit_model.cc

Issue 2425703003: Fix failing DCHECK in AutoCompleteInput() (Closed)
Patch Set: Created 4 years, 2 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/ui/omnibox/omnibox_view_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698