Commit 88c39aaf authored by oshima@google.com's avatar oshima@google.com

Fix range comparison. Get space to accept keyword work.

 I overlooked this placeholder code to fix.

BUG=none
TEST=enabled AcceptKeywordBySpaceTest for views-implementation

Review URL: http://codereview.chromium.org/6266015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72185 0039d316-1c4b-4281-b951-d872f2087c98
parent 0c3c986b
......@@ -984,4 +984,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, BasicTextOperations) {
BasicTextOperationsTest();
}
IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, AcceptKeywordBySpace) {
AcceptKeywordBySpaceTest();
}
#endif
......@@ -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
......
......@@ -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|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment