浏览代码

Fix: Moving to the same position is not handled by the Differ as a change.

Oskar Wróbel 6 年之前
父节点
当前提交
b6e6dd4084
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 6 0
      packages/ckeditor5-engine/src/model/differ.js
  2. 11 0
      packages/ckeditor5-engine/tests/model/differ.js

+ 6 - 0
packages/ckeditor5-engine/src/model/differ.js

@@ -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 );
 

+ 11 - 0
packages/ckeditor5-engine/tests/model/differ.js

@@ -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', () => {