From 894e8a603290f2168f71b6bd90c9b345a84f273e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 22 Dec 2017 17:36:44 +0100 Subject: [PATCH] [poincare] Fix main layout edition. If its only child is empty, remove it before adding another child. Change-Id: I3047f17c69ff14787e172d99b6e0b3e1f4096f26 --- poincare/src/layout/expression_layout.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/poincare/src/layout/expression_layout.cpp b/poincare/src/layout/expression_layout.cpp index 3b5bc8316..d4410fb08 100644 --- a/poincare/src/layout/expression_layout.cpp +++ b/poincare/src/layout/expression_layout.cpp @@ -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;