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 4c3a2782776335c03ee4aca6c61f16876b685e55..e9fd507c1c66e3999e1de6bffcfd1fd5b7fe8ed6 100644 |
--- a/components/omnibox/browser/omnibox_edit_model.cc |
+++ b/components/omnibox/browser/omnibox_edit_model.cc |
@@ -370,9 +370,11 @@ void OmniboxEditModel::Revert() { |
keyword_.clear(); |
is_keyword_hint_ = false; |
has_temporary_text_ = false; |
- view_->SetWindowTextAndCaretPos(permanent_text_, |
- has_focus() ? permanent_text_.length() : 0, |
- false, true); |
+ size_t start, end; |
+ view_->GetSelectionBounds(&start, &end); |
+ view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, false); |
+ view_->SetWindowTextAndCaretPos( |
+ permanent_text_, std::min(permanent_text_.length(), start), false, true); |
client_->OnRevert(); |
} |