diff --git a/poincare/src/horizontal_layout_node.cpp b/poincare/src/horizontal_layout_node.cpp index bdfa8d9b2..7ac7cf111 100644 --- a/poincare/src/horizontal_layout_node.cpp +++ b/poincare/src/horizontal_layout_node.cpp @@ -404,8 +404,8 @@ void HorizontalLayoutRef::mergeChildrenAtIndex(HorizontalLayoutRef h, int index, LayoutRef nextPointedLayout(nullptr); LayoutCursor::Position nextPosition = LayoutCursor::Position::Left; - if (index < numberOfChildren()) { - nextPointedLayout = childAtIndex(index); + if (newIndex < numberOfChildren()) { + nextPointedLayout = childAtIndex(newIndex); nextPosition = LayoutCursor::Position::Left; } else { nextPointedLayout = *this;