This looks to fix the selection history slicing bug described in T54927. The problem appears to have been the while loop at the end of function "bpy_bmeditselseq_subscript_slice" assigning the "next" pointer item to "ese" before appended the initial "ese" head data to the list that the funtion returns.
This can be verified by printing out the mesh element's index value before and after the while loop is run with:
printf("\n ese->ele->head.index: %d\n", ese->ele->head.index);Cleaner fix than shown in diff?
/* add items until stop */
do {
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head));
count++;
if (count == stop) {
break;
}
} while (ese = ese->next);