浏览代码

Fixed: InputCommand should not create empty insert deltas.

Szymon Cofalik 8 年之前
父节点
当前提交
b108ab1d3c
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 3 1
      packages/ckeditor5-typing/src/inputcommand.js
  2. 10 0
      packages/ckeditor5-typing/tests/inputcommand.js

+ 3 - 1
packages/ckeditor5-typing/src/inputcommand.js

@@ -84,7 +84,9 @@ export default class InputCommand extends Command {
 				this._buffer.batch.remove( range );
 			}
 
-			this._buffer.batch.weakInsert( range.start, text );
+			if ( text ) {
+				this._buffer.batch.weakInsert( range.start, text );
+			}
 
 			if ( resultRange ) {
 				this.editor.data.model.selection.setRanges( [ resultRange ] );

+ 10 - 0
packages/ckeditor5-typing/tests/inputcommand.js

@@ -216,6 +216,16 @@ describe( 'InputCommand', () => {
 			expect( getData( doc, { selection: true } ) ).to.be.equal( '<p>fo[]obar</p>' );
 			expect( buffer.size ).to.be.equal( 0 );
 		} );
+
+		it( 'does not create insert delta when no text given', () => {
+			setData( doc, '<p>foo[]bar</p>' );
+
+			const version = doc.version;
+
+			editor.execute( 'input' );
+
+			expect( doc.version ).to.equal( version );
+		} );
 	} );
 
 	describe( 'destroy', () => {