Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 60024c0

Browse files
authored
Merge pull request #1150 from ckeditor/t/ckeditor5-undo/65/1
Fix: Undo did no changes instead of merging elements, in a scenario when an element was split and then the "new" element was removed. See https://github.com/ckeditor/ckeditor5-undo/issues/65#issuecomment-323682195.
2 parents 9ae8e5d + 5a5610e commit 60024c0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/model/delta/basic-transformations.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ addTransformationCase( MarkerDelta, RenameDelta, transformMarkerDelta );
141141

142142
// Add special case for MoveDelta x MergeDelta transformation.
143143
addTransformationCase( MoveDelta, MergeDelta, ( a, b, context ) => {
144-
// Do not apply special transformation case if `MergeDelta` has `NoOperation` as the second operation.
145-
if ( !b.position ) {
144+
const undoMode = context.aWasUndone || context.bWasUndone;
145+
146+
// Do not apply special transformation case in undo mode or if `MergeDelta` has `NoOperation` as the second operation.
147+
if ( undoMode || !b.position ) {
146148
return defaultTransform( a, b, context );
147149
}
148150

@@ -185,8 +187,10 @@ addTransformationCase( MergeDelta, InsertDelta, ( a, b, context ) => {
185187

186188
// Add special case for MergeDelta x MoveDelta transformation.
187189
addTransformationCase( MergeDelta, MoveDelta, ( a, b, context ) => {
188-
// Do not apply special transformation case if `MergeDelta` has `NoOperation` as the second operation.
189-
if ( !a.position ) {
190+
const undoMode = context.aWasUndone || context.bWasUndone;
191+
192+
// Do not apply special transformation case in undo mode or if `MergeDelta` has `NoOperation` as the second operation.
193+
if ( undoMode || !a.position ) {
190194
return defaultTransform( a, b, context );
191195
}
192196

0 commit comments

Comments
 (0)