[poincare/code_point_layout] Fix collapsing

Scenario: Enter "(12/34 * 10)" then press "Divide" -> the numerator of
the division was not the whole parenthesed expression
This commit is contained in:
Léa Saviot
2020-03-09 16:26:24 +01:00
committed by RubenNumworks
parent 1dc6e77049
commit 5ca6b7dbf8

View File

@@ -58,22 +58,22 @@ bool CodePointLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goin
}
return false;
}
}
if (isMultiplicationCodePoint()) {
/* We want '*' to be collapsable only if the following brother is not a
* fraction, so that the user can write intuitively "1/2 * 3/4". */
Layout thisRef = CodePointLayout(this);
Layout parent = thisRef.parent();
if (!parent.isUninitialized()) {
int indexOfThis = parent.indexOfChild(thisRef);
Layout brother;
if (indexOfThis > 0 && goingLeft) {
brother = parent.childAtIndex(indexOfThis-1);
} else if (indexOfThis < parent.numberOfChildren() - 1 && !goingLeft) {
brother = parent.childAtIndex(indexOfThis+1);
}
if (!brother.isUninitialized() && brother.type() == LayoutNode::Type::FractionLayout) {
return false;
if (isMultiplicationCodePoint()) {
/* We want '*' to be collapsable only if the following brother is not a
* fraction, so that the user can write intuitively "1/2 * 3/4". */
Layout thisRef = CodePointLayout(this);
Layout parent = thisRef.parent();
if (!parent.isUninitialized()) {
int indexOfThis = parent.indexOfChild(thisRef);
Layout brother;
if (indexOfThis > 0 && goingLeft) {
brother = parent.childAtIndex(indexOfThis-1);
} else if (indexOfThis < parent.numberOfChildren() - 1 && !goingLeft) {
brother = parent.childAtIndex(indexOfThis+1);
}
if (!brother.isUninitialized() && brother.type() == LayoutNode::Type::FractionLayout) {
return false;
}
}
}
}