mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Only act on selection change if it changed
This commit is contained in:
parent
68a0026f56
commit
ee1caca875
|
@ -61,15 +61,21 @@ es.SurfaceModel.prototype.getSelection = function() {
|
|||
*/
|
||||
es.SurfaceModel.prototype.select = function( selection, isManual ) {
|
||||
selection.normalize();
|
||||
|
||||
this.selection = selection;
|
||||
|
||||
if ( isManual ) {
|
||||
// check if the last thing is a selection, if so, swap it.
|
||||
this.pushSelection( selection );
|
||||
if (
|
||||
// First selection
|
||||
!this.selection ||
|
||||
// From changed
|
||||
selection.from !== this.selection.from ||
|
||||
// To changed
|
||||
selection.to !== this.selection.to
|
||||
) {
|
||||
this.selection = selection;
|
||||
if ( isManual ) {
|
||||
// check if the last thing is a selection, if so, swap it.
|
||||
this.pushSelection( selection );
|
||||
}
|
||||
this.emit( 'select', this.selection.clone() );
|
||||
}
|
||||
|
||||
this.emit( 'select', this.selection.clone() );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue