Skip to content

Commit 81c12ac

Browse files
committed
Fix an edge case on the DragMarker position logic
1 parent 6506d62 commit 81c12ac

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ fun LongPressMenuEditor(modifier: Modifier = Modifier) {
168168
} else {
169169
var i = rawItem.index
170170
// make sure it is not possible to move items in between a *Caption and a HeaderBox
171-
val offsetForRemovingPrev = if (prevDragMarkerIndex < rawItem.index) 1 else 0
172-
if (!items[i - offsetForRemovingPrev].isDraggable) i += 1
173-
if (items[i - offsetForRemovingPrev] == ItemInList.HeaderBox) i += 1
171+
if (!items[i].isDraggable) i += 1
172+
if (i < items.size && items[i] == ItemInList.HeaderBox) i += 1
173+
if (i > rawItem.index && prevDragMarkerIndex < rawItem.index) i -= 1
174174
i
175175
}
176176

0 commit comments

Comments
 (0)