Fix off-by-one error in TransclusionModel when moving items

The error occurs when moving an item down (increasing index) which
removes the item, adjusts the index and then inserts the item. The index
shouldn't be adjusted when moving one down, however, because once
removed everything shifts and the +1 index set initially to move it is
still good.

Change-Id: I44bd2b3eb4bbbef58a6ac181e75969ec7c2cab6f
This commit is contained in:
Trevor Parscal 2014-02-27 16:04:15 -08:00 committed by Catrope
parent 315f10cea4
commit 3edad8d0da

View file

@ -117,7 +117,7 @@ ve.dm.MWTransclusionModel.prototype.process = function ( queue ) {
existing = ve.indexOf( item.add, this.parts ); existing = ve.indexOf( item.add, this.parts );
if ( existing !== -1 ) { if ( existing !== -1 ) {
this.removePart( item.add ); this.removePart( item.add );
if ( index && index > existing ) { if ( index && existing + 1 < index ) {
index--; index--;
} }
} }