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

Commit

Permalink
Fix: Moving to the same position is not handled by the Differ as a ch…
Browse files Browse the repository at this point in the history
…ange.
  • Loading branch information
oskarwrobel committed Feb 7, 2019
1 parent c31bea6 commit de58e4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/model/differ.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export default class Differ {
case 'remove':
case 'move':
case 'reinsert': {
// When range is moved to the same position then not mark it as a change.
// See: https://github.com/ckeditor/ckeditor5-engine/issues/1664.
if ( operation.sourcePosition.isEqual( operation.targetPosition ) ) {
return;
}

const sourceParentInserted = this._isInInsertedElement( operation.sourcePosition.parent );
const targetParentInserted = this._isInInsertedElement( operation.targetPosition.parent );

Expand Down
11 changes: 11 additions & 0 deletions tests/model/differ.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,17 @@ describe( 'Differ', () => {
] );
} );
} );

// https://github.com/ckeditor/ckeditor5-engine/issues/1664
it( 'move to the same position', () => {
const position = new Position( root, [ 0 ] );

model.change( () => {
move( position, 1, position );

expectChanges( [] );
} );
} );
} );

describe( 'rename', () => {
Expand Down

0 comments on commit de58e4e

Please sign in to comment.