Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(956)

Unified Diff: ui/views/controls/textfield/textfield_views_model.cc

Issue 8823007: Don't merge replace edit if previous edit is delete edit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_views_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_views_model.cc
diff --git a/ui/views/controls/textfield/textfield_views_model.cc b/ui/views/controls/textfield/textfield_views_model.cc
index 5c509865363922aef86cd3dc26459aa4ad7eea88..77485c6616db42904df2bd61c4b20dffc29bfc23 100644
--- a/ui/views/controls/textfield/textfield_views_model.cc
+++ b/ui/views/controls/textfield/textfield_views_model.cc
@@ -58,8 +58,12 @@ class Edit {
// successful, or false otherwise. Merged edit will be deleted after
// redo and should not be reused.
bool Merge(const Edit* edit) {
- if (edit->merge_with_previous()) {
- MergeSet(edit);
+ // Don't merge if previous edit is DELETE. This happens when a
+ // user deletes characters then hits return. In this case, the
+ // delete should be treated as separate edit that can be undone
+ // and should not be merged with the replace edit.
+ if (type_ != DELETE_EDIT && edit->merge_with_previous()) {
+ MergeReplace(edit);
return true;
}
return mergeable() && edit->mergeable() && DoMerge(edit);
@@ -113,10 +117,10 @@ class Edit {
// Returns the end index of the |new_text_|.
size_t new_text_end() const { return new_text_start_ + new_text_.length(); }
- // Merge the Set edit into the current edit. This is a special case to
+ // Merge the replace edit into the current edit. This is a special case to
// handle an omnibox setting autocomplete string after new character is
// typed in.
- void MergeSet(const Edit* edit) {
+ void MergeReplace(const Edit* edit) {
CHECK_EQ(REPLACE_EDIT, edit->type_);
CHECK_EQ(0U, edit->old_text_start_);
CHECK_EQ(0U, edit->new_text_start_);
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_views_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698