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

Commit c9932b8

Browse files
author
Piotr Jasiun
authoredFeb 8, 2019
Merge pull request #1669 from ckeditor/t/1668
Fix: `MarkerOperation` transformation in undo. Closes #1668.
2 parents 7dfaae6 + ab6636f commit c9932b8

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed
 

‎src/model/writer.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1317,13 +1317,11 @@ export default class Writer {
13171317
let isAffected = false;
13181318

13191319
if ( type == 'move' ) {
1320-
const intersecting =
1320+
isAffected =
13211321
positionOrRange.containsPosition( markerRange.start ) ||
13221322
positionOrRange.start.isEqual( markerRange.start ) ||
13231323
positionOrRange.containsPosition( markerRange.end ) ||
13241324
positionOrRange.end.isEqual( markerRange.end );
1325-
1326-
isAffected = intersecting && !positionOrRange.containsRange( markerRange );
13271325
} else {
13281326
// if type == 'merge'.
13291327
const elementBefore = positionOrRange.nodeBefore;

‎tests/model/operation/transform/undo.js

+47
Original file line numberDiff line numberDiff line change
@@ -527,4 +527,51 @@ describe( 'transform', () => {
527527
'<paragraph>B<m1:end></m1:end>ar</paragraph>'
528528
);
529529
} );
530+
531+
// https://github.com/ckeditor/ckeditor5-engine/issues/1668
532+
it( 'marker and moves with undo-redo-undo', () => {
533+
john.setData( '<paragraph>X[]Y</paragraph>' );
534+
535+
const inputBufferBatch = john.editor.commands.get( 'input' ).buffer.batch;
536+
537+
john.editor.model.enqueueChange( inputBufferBatch, () => {
538+
john.type( 'a' );
539+
john.type( 'b' );
540+
john.type( 'c' );
541+
542+
john.setSelection( [ 0, 1 ], [ 0, 4 ] );
543+
john.setMarker( 'm1' );
544+
} );
545+
546+
expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
547+
548+
john.setSelection( [ 0, 0 ], [ 0, 5 ] );
549+
john._processExecute( 'delete' );
550+
551+
expectClients( '<paragraph></paragraph>' );
552+
553+
john.undo();
554+
555+
expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
556+
557+
john.undo();
558+
559+
expectClients( '<paragraph>XY</paragraph>' );
560+
561+
john.redo();
562+
563+
expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
564+
565+
john.redo();
566+
567+
expectClients( '<paragraph></paragraph>' );
568+
569+
john.undo();
570+
571+
expectClients( '<paragraph>X<m1:start></m1:start>abc<m1:end></m1:end>Y</paragraph>' );
572+
573+
john.undo();
574+
575+
expectClients( '<paragraph>XY</paragraph>' );
576+
} );
530577
} );

0 commit comments

Comments
 (0)