From c476ea5380aefe5e6ba372e7d364a4491ed96cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 25 Jan 2019 09:44:31 +0100 Subject: [PATCH] [escher/text_field] Fix removeCodePoint rect dirtying --- escher/src/text_field.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index d88407ee1..2ee9ef894 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -145,6 +145,11 @@ KDSize TextField::ContentView::minimalSizeForOptimalDisplay() const { bool TextField::ContentView::removeCodePoint() { assert(m_isEditing); + if (m_horizontalAlignment > 0.0f) { + /* Reload the view. If we do it later, the text beins supposedly shorter, we + * will not clean the first char. */ + reloadRectFromPosition(m_draftTextBuffer); + } // Remove the code point if possible CodePoint removedCodePoint = 0; int removedSize = UTF8Helper::RemovePreviousCodePoint(m_draftTextBuffer, const_cast(cursorLocation()), &removedCodePoint); @@ -157,10 +162,7 @@ bool TextField::ContentView::removeCodePoint() { m_currentDraftTextLength-= removedSize; assert(m_draftTextBuffer[m_currentDraftTextLength] == 0); - // Reload the view and set the cursor location - if (m_horizontalAlignment > 0.0f) { - reloadRectFromPosition(m_draftTextBuffer); - } + // Set the cursor location and reload the view assert(cursorLocation() - removedSize >= m_draftTextBuffer); setCursorLocation(cursorLocation() - removedSize); if (m_horizontalAlignment == 0.0f) {