From f0c324835fe5a42a2346aee842a2b4e9956362e9 Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 23 Oct 2025 03:37:10 +0200 Subject: [PATCH] Fix an edge case on the DragMarker position logic --- .../newpipe/ui/components/menu/LongPressMenuEditor.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt b/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt index 9eb1b0666..3f0a494f7 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt @@ -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 }