diff --git a/poincare/include/poincare/expression_layout.h b/poincare/include/poincare/expression_layout.h index 1694204e8..9dff32dfb 100644 --- a/poincare/include/poincare/expression_layout.h +++ b/poincare/include/poincare/expression_layout.h @@ -125,6 +125,7 @@ public: virtual bool isRightBracket() const { return false; } virtual bool isEmpty() const { return false; } virtual bool isMatrix() const { return false; } + virtual bool hasUpperLeftIndex() const { return false; } virtual char XNTChar() const; protected: diff --git a/poincare/src/layout/nth_root_layout.h b/poincare/src/layout/nth_root_layout.h index f5d31c723..c62b896e0 100644 --- a/poincare/src/layout/nth_root_layout.h +++ b/poincare/src/layout/nth_root_layout.h @@ -26,6 +26,7 @@ public: /* Expression Engine */ int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; + bool hasUpperLeftIndex() const override { return numberOfChildren() > 1; } protected: void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; KDSize computeSize() override; diff --git a/poincare/src/layout/vertical_offset_layout.cpp b/poincare/src/layout/vertical_offset_layout.cpp index 14bb1da9f..f921efa76 100644 --- a/poincare/src/layout/vertical_offset_layout.cpp +++ b/poincare/src/layout/vertical_offset_layout.cpp @@ -246,7 +246,12 @@ KDSize VerticalOffsetLayout::computeSize() { KDSize indiceSize = indiceLayout()->size(); KDCoordinate width = indiceSize.width(); if (m_type == Type::Superscript) { - width += 5; + assert(m_parent != nullptr); + assert(m_parent->isHorizontal()); + int indexInParent = m_parent->indexOfChild(this); + if (indexInParent < m_parent-> numberOfChildren() - 1 && m_parent->editableChild(indexInParent + 1)->hasUpperLeftIndex()) { + width += 5; + } } KDCoordinate height = 0; if (m_type == Type::Subscript) {