[poincare] Fix main layout edition.

If its only child is empty, remove it before adding another child.

Change-Id: I3047f17c69ff14787e172d99b6e0b3e1f4096f26
This commit is contained in:
Léa Saviot
2017-12-22 17:36:44 +01:00
parent 2c5e1b99bb
commit 894e8a6032

View File

@@ -141,6 +141,10 @@ void ExpressionLayout::addBrother(ExpressionLayoutCursor * cursor, ExpressionLay
}
// If there is no parent, the pointed layout is the main horizontal layout.
// Add the "brother" as a child.
// If there is only one empty child, remove it before adding the layout.
if (numberOfChildren() == 1 && editableChild(0)->isEmpty()) {
removeChildAtIndex(0, true);
}
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
addChildAtIndex(brother, 0);
return;