From 4e165153441ee9407cb6d6ced61287b414498cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 23 Apr 2018 17:23:00 +0200 Subject: [PATCH] [poincare] Do not insert an empty base for power layouts. This should be done only if the power is added to an horizontal layout with no child. Change-Id: I5f2f501420da127a2ed42d2b01042ec5968f488f --- poincare/src/expression_layout_cursor.cpp | 25 +++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) 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() {