Fix paste position from parent

This commit is contained in:
SiboVG 2022-08-18 21:29:29 +02:00
parent 3364b29189
commit 41cf976bf8

View File

@ -433,12 +433,13 @@ public class RocketActions {
return new Pair<RocketComponent, Integer>(destComponent, destComponent.getChildCount()); return new Pair<RocketComponent, Integer>(destComponent, destComponent.getChildCount());
RocketComponent parent = destComponent.getParent(); RocketComponent parent = destComponent.getParent();
return getPastePositionFromParent(srcComponent, parent); return getPastePositionFromParent(srcComponent, destComponent, parent);
} }
private Pair<RocketComponent, Integer> getPastePositionFromParent(RocketComponent component, RocketComponent parent) { private Pair<RocketComponent, Integer> getPastePositionFromParent(RocketComponent srcComponent, RocketComponent destComponent,
if (parent != null && parent.isCompatible(component)) { RocketComponent parent) {
int index = parent.getChildPosition(parent) + 1; if (parent != null && parent.isCompatible(srcComponent)) {
int index = parent.getChildPosition(destComponent) + 1;
return new Pair<>(parent, index); return new Pair<>(parent, index);
} }