Delete last template search result, not a random one

Because the API uses a generator, the search results are ordered
alphabetically. The actual search result ranking is in a .index
field. This code accidentially deleted the alphabetically lowest
template instead of the least relevant one.

Change-Id: I79de024feb569e9f06bedab908a6509a4d4fa99b
This commit is contained in:
Thiemo Kreuz 2021-07-08 15:31:39 +02:00
parent ba1718ea11
commit 12dca65912

View file

@ -235,7 +235,9 @@ ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response )
newPage.index = 1;
pages.unshift( newPage );
if ( pages.length > widget.limit ) {
pages.splice( widget.limit );
pages.sort( function ( a, b ) {
return a.index - b.index;
} ).splice( widget.limit );
}
}
}