Selaa lähdekoodia

Fix: `MarkerOperation` transformation in undo.

Szymon Cofalik 6 vuotta sitten
vanhempi
commit
5e8bfce54e

+ 1 - 3
packages/ckeditor5-engine/src/model/writer.js

@@ -1317,13 +1317,11 @@ export default class Writer {
 			let isAffected = false;
 
 			if ( type == 'move' ) {
-				const intersecting =
+				isAffected =
 					positionOrRange.containsPosition( markerRange.start ) ||
 					positionOrRange.start.isEqual( markerRange.start ) ||
 					positionOrRange.containsPosition( markerRange.end ) ||
 					positionOrRange.end.isEqual( markerRange.end );
-
-				isAffected = intersecting && !positionOrRange.containsRange( markerRange );
 			} else {
 				// if type == 'merge'.
 				const elementBefore = positionOrRange.nodeBefore;

+ 47 - 0
packages/ckeditor5-engine/tests/model/operation/transform/undo.js

@@ -527,4 +527,51 @@ describe( 'transform', () => {
 			'<paragraph>B<m1:end></m1:end>ar</paragraph>'
 		);
 	} );
+
+	// https://github.com/ckeditor/ckeditor5-engine/issues/1668
+	it( 'marker and moves with undo-redo-undo', () => {
+		john.setData( '<paragraph>X[]Y</paragraph>' );
+
+		const inputBufferBatch = john.editor.commands.get( 'input' ).buffer.batch;
+
+		john.editor.model.enqueueChange( inputBufferBatch, () => {
+			john.type( 'a' );
+			john.type( 'b' );
+			john.type( 'c' );
+
+			john.setSelection( [ 0, 1 ], [ 0, 4 ] );
+			john.setMarker( 'm1' );
+		} );
+
+		expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
+
+		john.setSelection( [ 0, 0 ], [ 0, 5 ] );
+		john._processExecute( 'delete' );
+
+		expectClients( '<paragraph></paragraph>' );
+
+		john.undo();
+
+		expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
+
+		john.undo();
+
+		expectClients( '<paragraph>XY</paragraph>' );
+
+		john.redo();
+
+		expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
+
+		john.redo();
+
+		expectClients( '<paragraph></paragraph>' );
+
+		john.undo();
+
+		expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
+
+		john.undo();
+
+		expectClients( '<paragraph>XY</paragraph>' );
+	} );
 } );