mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/layout] Tracking issue in addSibling
The addSibling method sometimes did not take into account the offset
introduced by adding parentheses, leading to some issues :
- Type 2 SQUARE RIGHTPARENTHESIS LEFT SQUARE. Parentheses are added
but the new square should be outside, between the two right
parentheses.
Change-Id: Ifbc49cee2cd03c4511fc5a678d6d5d42243f4a22
This commit is contained in:
committed by
Émilie Feral
parent
be8e452285
commit
7c27440916
@@ -176,7 +176,13 @@ void Layout::addSibling(LayoutCursor * cursor, Layout sibling, bool moveCursor)
|
||||
assert(!p.isUninitialized());
|
||||
if (p.type() == LayoutNode::Type::HorizontalLayout) {
|
||||
int indexInParent = p.indexOfChild(*this);
|
||||
int siblingIndex = cursor->position() == LayoutCursor::Position::Left ? indexInParent : indexInParent + 1;
|
||||
int indexOfCursor = p.indexOfChild(cursor->layout());
|
||||
/* indexOfCursor == -1 if cursor->layout() is not a child of p. This should
|
||||
* never happen, as addSibling is only called from inside
|
||||
* LayoutField::handleEventWithText, and LayoutField is supposed to keep
|
||||
* its cursor up to date.*/
|
||||
assert(indexOfCursor >= 0);
|
||||
int siblingIndex = cursor->position() == LayoutCursor::Position::Left ? indexOfCursor : indexOfCursor + 1;
|
||||
|
||||
/* Special case: If the neighbour sibling is a VerticalOffsetLayout, let it
|
||||
* handle the insertion of the new sibling. Do not enter the special case if
|
||||
|
||||
@@ -236,7 +236,7 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode
|
||||
// Add the Right parenthesis
|
||||
RightParenthesisLayout rightParenthesis = RightParenthesisLayout::Builder();
|
||||
if (cursor->position() == LayoutCursor::Position::Right) {
|
||||
parentRef.addChildAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr);
|
||||
parentRef.addChildAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr);
|
||||
} else {
|
||||
assert(cursor->position() == LayoutCursor::Position::Left);
|
||||
parentRef.addChildAtIndex(rightParenthesis, idxInParent, parentRef.numberOfChildren(), nullptr);
|
||||
|
||||
Reference in New Issue
Block a user