Fix an edge case on the DragMarker position logic

This commit is contained in:
Stypox 2025-10-23 03:37:10 +02:00
parent e350b10b14
commit f0c324835f
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -171,9 +171,9 @@ fun LongPressMenuEditor(modifier: Modifier = Modifier) {
} else {
var i = rawItem.index
// make sure it is not possible to move items in between a *Caption and a HeaderBox
val offsetForRemovingPrev = if (prevDragMarkerIndex < rawItem.index) 1 else 0
if (!items[i - offsetForRemovingPrev].isDraggable) i += 1
if (items[i - offsetForRemovingPrev] == ItemInList.HeaderBox) i += 1
if (!items[i].isDraggable) i += 1
if (i < items.size && items[i] == ItemInList.HeaderBox) i += 1
if (i > rawItem.index && prevDragMarkerIndex < rawItem.index) i -= 1
i
}