Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js |
— | — | @@ -63,8 +63,11 @@ |
64 | 64 | * @param {es.Range} selection |
65 | 65 | * @param {Boolean} combine Whether to prevent this transaction from causing a state push |
66 | 66 | */ |
67 | | -es.SurfaceModel.prototype.select = function( selection ) { |
| 67 | +es.SurfaceModel.prototype.select = function( selection, combine ) { |
68 | 68 | selection.normalize(); |
| 69 | + if ( !combine && this.shouldPushState( selection ) ) { |
| 70 | + this.pushState(); |
| 71 | + } |
69 | 72 | // Filter out calls to select if they do not change the selection values |
70 | 73 | var selectionChanged = !this.selection || ( |
71 | 74 | this.selection.from !== selection.from || |
— | — | @@ -77,6 +80,7 @@ |
78 | 81 | selection.from - this.states[this.states.length - 1].from |
79 | 82 | ); |
80 | 83 | } |
| 84 | + this.currentState.push( selection ); |
81 | 85 | this.selection = selection; |
82 | 86 | if ( selectionChanged ) { |
83 | 87 | this.emit( 'select', this.selection.clone() ); |
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | } |
376 | 376 | } |
377 | 377 | // Apply new selection |
378 | | - this.model.select( selection ); |
| 378 | + this.model.select( selection, true ); |
379 | 379 | } |
380 | 380 | }; |
381 | 381 | |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | this.model.getDocument().getRelativeContentOffset( |
519 | 519 | this.model.getDocument().getContentLength(), -1 |
520 | 520 | ) |
521 | | - ) ); |
| 521 | + ), true ); |
522 | 522 | break; |
523 | 523 | } |
524 | 524 | // Insert content (maybe) |
— | — | @@ -575,7 +575,7 @@ |
576 | 576 | } |
577 | 577 | |
578 | 578 | selection.from = selection.to = targetOffset; |
579 | | - this.model.select( selection ); |
| 579 | + this.model.select( selection, true ); |
580 | 580 | |
581 | 581 | if ( sourceNode === targetNode || |
582 | 582 | ( typeof sourceSplitableNode !== 'undefined' && |
— | — | @@ -610,7 +610,7 @@ |
611 | 611 | tx = this.model.getDocument().prepareRemoval( selection ); |
612 | 612 | this.model.transact( tx, true ); |
613 | 613 | selection.from = selection.to = selection.start; |
614 | | - this.model.select( selection ); |
| 614 | + this.model.select( selection, true ); |
615 | 615 | } |
616 | 616 | }; |
617 | 617 | |
— | — | @@ -662,7 +662,7 @@ |
663 | 663 | selection.from = selection.to = |
664 | 664 | this.model.getDocument().getRelativeContentOffset( selection.to, 1 ); |
665 | 665 | } |
666 | | - this.model.select( selection ); |
| 666 | + this.model.select( selection, true ); |
667 | 667 | }; |
668 | 668 | |
669 | 669 | es.SurfaceView.prototype.insertFromInput = function() { |
— | — | @@ -702,7 +702,7 @@ |
703 | 703 | // Move the selection |
704 | 704 | selection.from += val.length; |
705 | 705 | selection.to += val.length; |
706 | | - this.model.select( selection ); |
| 706 | + this.model.select( selection, true ); |
707 | 707 | } |
708 | 708 | }; |
709 | 709 | |