Skip to content

Commit d2b5f9f

Browse files
committed
Fix an edge case on the DragMarker position logic
1 parent 5391a5b commit d2b5f9f

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
@@ -171,9 +171,9 @@ fun LongPressMenuEditor(modifier: Modifier = Modifier) {
171171
} else {
172172
var i = rawItem.index
173173
// make sure it is not possible to move items in between a *Caption and a HeaderBox
174-
val offsetForRemovingPrev = if (prevDragMarkerIndex < rawItem.index) 1 else 0
175-
if (!items[i - offsetForRemovingPrev].isDraggable) i += 1
176-
if (items[i - offsetForRemovingPrev] == ItemInList.HeaderBox) i += 1
174+
if (!items[i].isDraggable) i += 1
175+
if (i < items.size && items[i] == ItemInList.HeaderBox) i += 1
176+
if (i > rawItem.index && prevDragMarkerIndex < rawItem.index) i -= 1
177177
i
178178
}
179179

0 commit comments

Comments
 (0)