[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
This commit is contained in:
Léa Saviot
2018-04-23 17:23:00 +02:00
parent 0ae7c8a723
commit 4e16515344

View File

@@ -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() {