Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -354,9 +354,15 @@ |
355 | 355 | var val = this.$input.val(); |
356 | 356 | this.$input.val( '' ); |
357 | 357 | if ( val.length > 0 ) { |
358 | | - var transaction = this.documentView.model.prepareInsertion( this.selection.to, val.split('') ); |
359 | | - this.documentView.model.commit ( transaction ); |
360 | | - this.selection.from = this.selection.to += val.length; |
| 358 | + if ( this.selection.from != this.selection.to ) { |
| 359 | + var tx = this.documentView.model.prepareRemoval( this.selection ); |
| 360 | + this.documentView.model.commit( tx ); |
| 361 | + this.documentView.clearSelection(); |
| 362 | + } |
| 363 | + |
| 364 | + var tx = this.documentView.model.prepareInsertion( this.selection.from, val.split('') ); |
| 365 | + this.documentView.model.commit ( tx ); |
| 366 | + this.selection.to = this.selection.from += val.length; |
361 | 367 | this.showCursor(); |
362 | 368 | } |
363 | 369 | }; |