From 2e03812cdb59bfe597df4839df428d2ffe1588fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 17 May 2018 11:45:26 +0200 Subject: [PATCH] [poincare] Fix cursor position when layout field is not editing Change-Id: I39fa348a3e567621f4574b2e331b75a836353306 --- escher/src/expression_layout_field.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/escher/src/expression_layout_field.cpp b/escher/src/expression_layout_field.cpp index 09e32e2e0..17954495d 100644 --- a/escher/src/expression_layout_field.cpp +++ b/escher/src/expression_layout_field.cpp @@ -281,12 +281,17 @@ void ExpressionLayoutField::insertLayoutAtCursor(Poincare::ExpressionLayout * la bool layoutWillBeMerged = layout->isHorizontal(); Poincare::ExpressionLayout * lastMergedLayoutChild = layoutWillBeMerged ? layout->editableChild(layout->numberOfChildren()-1) : nullptr; m_contentView.cursor()->addLayoutAndMoveCursor(layout); - if (pointedLayout != nullptr && (pointedLayout != layout || !layoutWillBeMerged)) { - m_contentView.cursor()->setPointedExpressionLayout(pointedLayout); - m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right); - } else if (!layoutWillBeMerged) { - m_contentView.cursor()->setPointedExpressionLayout(layout->layoutToPointWhenInserting()); + if (!isEditing()) { + m_contentView.cursor()->setPointedExpressionLayout(expressionLayout()); m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right); + } else { + if (pointedLayout != nullptr && (pointedLayout != layout || !layoutWillBeMerged)) { + m_contentView.cursor()->setPointedExpressionLayout(pointedLayout); + m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right); + } else if (!layoutWillBeMerged) { + m_contentView.cursor()->setPointedExpressionLayout(layout->layoutToPointWhenInserting()); + m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right); + } } m_contentView.cursor()->pointedExpressionLayout()->addGreySquaresToAllMatrixAncestors(); m_contentView.cursor()->hideEmptyLayoutIfNeeded();