Merge "Fix: Undo for drag and drop."
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index cbac697..5eaabe7 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -2345,7 +2345,7 @@
}
mCorrectionHighlighter.highlight(info);
- mUndoInputFilter.onCommitCorrection();
+ mUndoInputFilter.freezeLastEdit();
}
void onScrollChanged() {
@@ -2477,6 +2477,7 @@
}
mTextView.beginBatchEdit();
+ mUndoInputFilter.freezeLastEdit();
try {
final int offset = mTextView.getOffsetForPosition(event.getX(), event.getY());
Object localState = event.getLocalState();
@@ -2526,6 +2527,7 @@
}
} finally {
mTextView.endBatchEdit();
+ mUndoInputFilter.freezeLastEdit();
}
}
@@ -5845,7 +5847,7 @@
return null;
}
- void onCommitCorrection() {
+ void freezeLastEdit() {
mEditor.mUndoManager.beginUpdate("Edit text");
EditOperation lastEdit = getLastEdit();
if (lastEdit != null) {
@@ -5906,7 +5908,6 @@
// Add this as the first edit.
if (DEBUG_UNDO) Log.d(TAG, "filter: adding first op " + edit);
um.addOperation(edit, UndoManager.MERGE_MODE_NONE);
- mPreviousOperationWasInSameBatchEdit = mIsUserEdit;
} else if (mergeMode == MERGE_EDIT_MODE_FORCE_MERGE) {
// Forced merges take priority because they could be the result of a non-user-edit
// change and this case should not create a new undo operation.
@@ -5918,7 +5919,6 @@
if (DEBUG_UNDO) Log.d(TAG, "non-user edit, new op " + edit);
um.commitState(mEditor.mUndoOwner);
um.addOperation(edit, UndoManager.MERGE_MODE_NONE);
- mPreviousOperationWasInSameBatchEdit = mIsUserEdit;
} else if (mergeMode == MERGE_EDIT_MODE_NORMAL && lastEdit.mergeWith(edit)) {
// Merge succeeded, nothing else to do.
if (DEBUG_UNDO) Log.d(TAG, "filter: merge succeeded, created " + lastEdit);
@@ -5927,8 +5927,8 @@
if (DEBUG_UNDO) Log.d(TAG, "filter: merge failed, adding " + edit);
um.commitState(mEditor.mUndoOwner);
um.addOperation(edit, UndoManager.MERGE_MODE_NONE);
- mPreviousOperationWasInSameBatchEdit = mIsUserEdit;
}
+ mPreviousOperationWasInSameBatchEdit = mIsUserEdit;
um.endUpdate();
}