summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_views.cc4
-rw-r--r--views/controls/textfield/textfield.h6
3 files changed, 10 insertions, 4 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index 5ecd047..6e00c93 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
@@ -984,4 +984,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, BasicTextOperations) {
BasicTextOperationsTest();
}
+IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, AcceptKeywordBySpace) {
+ AcceptKeywordBySpaceTest();
+}
+
#endif
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
index 357c7a2..f4935e0 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
@@ -484,7 +484,9 @@ bool AutocompleteEditViewViews::OnAfterPossibleChange() {
// See if the text or selection have changed since OnBeforePossibleChange().
std::wstring new_text = GetText();
text_changed_ = (new_text != text_before_change_);
- bool selection_differs = !sel_before_change_.Equals(new_sel);
+ bool selection_differs =
+ !((sel_before_change_.is_empty() && new_sel.is_empty()) ||
+ sel_before_change_.EqualsIgnoringDirection(new_sel));
// When the user has deleted text, we don't allow inline autocomplete. Make
// sure to not flag cases like selecting part of the text and then pasting
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index 90c8139..690e825 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -69,9 +69,9 @@ class TextRange {
// Returns the max of selected range.
size_t GetMax() const;
- // Returns true if |range| has same start, end position.
- bool Equals(const TextRange& range) const {
- return start_ == range.start_ && end_ == range.end_;
+ // Returns true if the the selection range is same ignoring the direction.
+ bool EqualsIgnoringDirection(const TextRange& range) const {
+ return GetMin() == range.GetMin() && GetMax() == range.GetMax();
}
// Set the range with |start| and |end|.