From a2981c22a58915fecbcf9e130e38ce6b9080c583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 25 Jun 2019 18:06:54 +0200 Subject: [PATCH] [escher/layout_field] Fix cursor position when inserting layout Scenario : In calculation, write 10/7, enter Go up, press OK on 10/7 -> the cursor is not on the right of the layout --- escher/src/layout_field.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index f771c6473..b691b73b8 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -310,8 +310,9 @@ void LayoutField::insertLayoutAtCursor(Layout layoutR, Poincare::Expression corr /* Move the cursor if needed. * - * If forceCursorRightOfLayout is true, there is no need to move the cursor - * because it already points to the right of the added layout. + * If forceCursorRightOfLayout is true and the layout has been merged, there + * is no need to move the cursor because it already points to the right of the + * added layouts. * * If the layout to point to has been merged, only its children have been * inserted in the layout. We already computed where the cursor should point, @@ -342,6 +343,9 @@ void LayoutField::insertLayoutAtCursor(Layout layoutR, Poincare::Expression corr assert(!cursorMergedLayout.isUninitialized()); m_contentView.cursor()->setLayout(cursorMergedLayout); m_contentView.cursor()->setPosition(LayoutCursor::Position::Right); + } else if (!layoutWillBeMerged) { + m_contentView.cursor()->setLayout(layoutR); + m_contentView.cursor()->setPosition(LayoutCursor::Position::Right); } // Handle matrices