diff --git a/escher/include/escher/layout_field.h b/escher/include/escher/layout_field.h index 7476727d2..d8c4694b1 100644 --- a/escher/include/escher/layout_field.h +++ b/escher/include/escher/layout_field.h @@ -87,11 +87,7 @@ private: bool selectionIsEmpty() const; void deleteSelection(); void invalidateInsertionCursor() { m_insertionCursor = Poincare::LayoutCursor(); } - void updateInsertionCursor() { - if (!m_insertionCursor.isDefined()) { - m_insertionCursor = m_cursor; - } - } + void updateInsertionCursor(); private: int numberOfSubviews() const override { return 2; } diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 4575f5258..6df1de2f0 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -234,6 +235,17 @@ void LayoutField::ContentView::deleteSelection() { resetSelection(); } +void LayoutField::ContentView::updateInsertionCursor() { + if (!m_insertionCursor.isDefined()) { + Layout l = m_cursor.layout(); + if (l.type() == LayoutNode::Type::EmptyLayout && static_cast(l).color() == EmptyLayoutNode::Color::Grey) { + // Don't set m_insertionCursor pointing to a layout which might disappear + return; + } + m_insertionCursor = m_cursor; + } +} + View * LayoutField::ContentView::subviewAtIndex(int index) { assert(0 <= index && index < numberOfSubviews()); View * m_views[] = {&m_expressionView, &m_cursorView};