diff options
author | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 21:18:07 +0000 |
---|---|---|
committer | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 21:18:07 +0000 |
commit | 96ed237d4c3d8cd9d1a16851b7094b476c6c95e9 (patch) | |
tree | 7a5b42328cbd7e1dd3ac986363fa99191ba9b89d /chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | |
parent | e9f575064ea212023b82ec27e36905a066cfc76d (diff) | |
download | chromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.zip chromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.tar.gz chromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.tar.bz2 |
Accept keyword by pressing space.
This CL disables implicit keyword accepting completely. The user can only
accept a keyword by pressing Tab or space explicitly while the keyword hint
UI is visible.
BUG=60972
TEST=interactive_ui_tests --gtest_filter=AutocompleteEditViewTest.AcceptKeywordBySpace
Review URL: http://codereview.chromium.org/6252003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_mac.mm')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index 207bd08..ba9736a 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -648,8 +648,9 @@ bool AutocompleteEditViewMac::OnAfterPossibleChange() { const std::wstring new_text(GetText()); const size_t length = new_text.length(); - const bool selection_differs = !NSEqualRanges(new_selection, - selection_before_change_); + const bool selection_differs = + (new_selection.length || selection_before_change_.length) && + !NSEqualRanges(new_selection, selection_before_change_); const bool at_end_of_edit = (length == new_selection.location); const bool text_differs = (new_text != text_before_change_) || !NSEqualRanges(marked_range_before_change_, GetMarkedRange()); @@ -810,10 +811,8 @@ bool AutocompleteEditViewMac::OnDoCommandBySelector(SEL cmd) { if (cmd == @selector(insertTab:) || cmd == @selector(insertTabIgnoringFieldEditor:)) { - if (model_->is_keyword_hint() && !model_->keyword().empty()) { - model_->AcceptKeyword(); - return true; - } + if (model_->is_keyword_hint()) + return model_->AcceptKeyword(); if (suggest_text_length_ > 0) { controller_->OnCommitSuggestedText(GetText()); @@ -939,10 +938,8 @@ void AutocompleteEditViewMac::OnPaste() { NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); const NSRange selectedRange = GetSelectedRange(); if ([editor shouldChangeTextInRange:selectedRange replacementString:s]) { - // If this paste will be replacing all the text, record that, so - // we can do different behaviors in such a case. - if (IsSelectAll()) - model_->on_paste_replacing_all(); + // Record this paste, so we can do different behavior. + model_->on_paste(); // Force a Paste operation to trigger the text_changed code in // OnAfterPossibleChange(), even if identical contents are pasted |