diff --git a/poincare/src/expression_layout_cursor.cpp b/poincare/src/expression_layout_cursor.cpp index 074a324dd..6aa8f482a 100644 --- a/poincare/src/expression_layout_cursor.cpp +++ b/poincare/src/expression_layout_cursor.cpp @@ -252,26 +252,15 @@ bool ExpressionLayoutCursor::privateShowHideEmptyLayoutIfNeeded(bool show) { } bool ExpressionLayoutCursor::baseForNewPowerLayout() { - // Returns true if the layout on the left of the pointed layout is suitable to - // be the base of a new power layout. - int numberOfOpenParenthesis = 0; - if (m_position == Position::Right - && m_pointedExpressionLayout->isCollapsable(&numberOfOpenParenthesis, true)) + /* Returns true if the layout on the left of the pointed layout is suitable to + * be the base of a new power layout: the base layout should be anything but + * an horizontal layout with no child. */ + if (m_pointedExpressionLayout->isHorizontal() + && m_pointedExpressionLayout->numberOfChildren() == 0) { - return true; + return false; } - if (m_pointedExpressionLayout->parent() != nullptr) { - int indexInParent = m_pointedExpressionLayout->parent()->indexOfChild(m_pointedExpressionLayout); - if (m_position == Position::Left - && m_pointedExpressionLayout->parent()->isHorizontal() - && indexInParent > 0 - && (m_pointedExpressionLayout->editableParent()->editableChild(indexInParent-1)->isEmpty() - || m_pointedExpressionLayout->editableParent()->editableChild(indexInParent-1)->isCollapsable(&numberOfOpenParenthesis, true))) - { - return true; - } - } - return false; + return true; } KDCoordinate ExpressionLayoutCursor::pointedLayoutHeight() {