This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,15 @@ export default class Differ {
149149 case 'remove' :
150150 case 'move' :
151151 case 'reinsert' : {
152+ // When range is moved to the same position then not mark it as a change.
153+ // See: https://github.com/ckeditor/ckeditor5-engine/issues/1664.
154+ if (
155+ operation . sourcePosition . isEqual ( operation . targetPosition ) ||
156+ operation . sourcePosition . getShiftedBy ( operation . howMany ) . isEqual ( operation . targetPosition )
157+ ) {
158+ return ;
159+ }
160+
152161 const sourceParentInserted = this . _isInInsertedElement ( operation . sourcePosition . parent ) ;
153162 const targetParentInserted = this . _isInInsertedElement ( operation . targetPosition . parent ) ;
154163
Original file line number Diff line number Diff line change @@ -629,6 +629,35 @@ describe( 'Differ', () => {
629629 ] ) ;
630630 } ) ;
631631 } ) ;
632+
633+ // https://github.com/ckeditor/ckeditor5-engine/issues/1664
634+ it ( 'move to the same position #1' , ( ) => {
635+ const position = new Position ( root , [ 0 ] ) ;
636+
637+ model . change ( ( ) => {
638+ move ( position , 1 , position ) ;
639+
640+ expectChanges ( [ ] ) ;
641+ } ) ;
642+ } ) ;
643+
644+ // https://github.com/ckeditor/ckeditor5-engine/issues/1664
645+ it ( 'move to the same position #2' , ( ) => {
646+ const sourcePosition = new Position ( root , [ 0 ] ) ;
647+ const targetPosition = new Position ( root , [ 2 ] ) ;
648+
649+ // Add two more elements to the root, now there are 4 paragraphs.
650+ root . _appendChild ( [
651+ new Element ( 'paragraph' ) ,
652+ new Element ( 'paragraph' )
653+ ] ) ;
654+
655+ model . change ( ( ) => {
656+ move ( sourcePosition , 2 , targetPosition ) ;
657+
658+ expectChanges ( [ ] ) ;
659+ } ) ;
660+ } ) ;
632661 } ) ;
633662
634663 describe ( 'rename' , ( ) => {
You can’t perform that action at this time.
0 commit comments