Chromium Code Reviews| 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..1ca056554db7f7441f86941ab2111b91d41c5d21 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 hit return. In this case, the delete |
|
msw
2011/12/07 01:23:35
nit: "hits".
optional nit: Other comments use one
oshima
2011/12/07 01:26:20
Done.
|
| + // should be treated as separate edit that can be undone and |
| + // should not be merged with the set. |
| + 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_); |