summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_popup_model.cc
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 04:17:41 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 04:17:41 +0000
commita210fefe3ce45708ec4cb66fa8f96d250602a9d9 (patch)
treed58e70d2ea154328744aa03c143ed82775fd44e8 /chrome/browser/autocomplete/autocomplete_popup_model.cc
parent85c4eafd31af67b19e55fbb2ed8bc17b1f068ddd (diff)
downloadchromium_src-a210fefe3ce45708ec4cb66fa8f96d250602a9d9.zip
chromium_src-a210fefe3ce45708ec4cb66fa8f96d250602a9d9.tar.gz
chromium_src-a210fefe3ce45708ec4cb66fa8f96d250602a9d9.tar.bz2
Fix text and selection's save/restore issue of omnibox when displaying temporary text.
This CL fixes issue 21362: The original text and selection can't be reverted correctly when pressing escape key in omnibox if currently selected line is not the default match. BUG=21362: The original text and selection can't be reverted correctly when pressing escape key in omnibox if currently selected line is not the default match. TEST=Input something in omnibox and make sure inline autocomplete is triggered, then press down to select another line, then press escape to revert to the default match and see of the original text and selection was reverted correctly. Review URL: http://codereview.chromium.org/194056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_popup_model.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index bce6ce9..8b0c9d1 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -109,9 +109,20 @@ void AutocompletePopupModel::SetSelectedLine(size_t line,
// eliminated and just become a call to the observer on the edit.
std::wstring keyword;
const bool is_keyword_hint = GetKeywordForMatch(match, &keyword);
- edit_model_->OnPopupDataChanged(
- reset_to_default ? std::wstring() : match.fill_into_edit,
- !reset_to_default, keyword, is_keyword_hint, match.type);
+
+ if (reset_to_default) {
+ std::wstring inline_autocomplete_text;
+ if ((match.inline_autocomplete_offset != std::wstring::npos) &&
+ (match.inline_autocomplete_offset < match.fill_into_edit.length())) {
+ inline_autocomplete_text =
+ match.fill_into_edit.substr(match.inline_autocomplete_offset);
+ }
+ edit_model_->OnPopupDataChanged(inline_autocomplete_text, false,
+ keyword, is_keyword_hint, match.type);
+ } else {
+ edit_model_->OnPopupDataChanged(match.fill_into_edit, true,
+ keyword, is_keyword_hint, match.type);
+ }
// Repaint old and new selected lines immediately, so that the edit doesn't
// appear to update [much] faster than the popup. We must not update