From dec857d807ad93e5ba0ccdc0ab921d911543bcc9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 23 Dec 2019 18:43:21 +0100 Subject: [PATCH] TextAreaWidget: Fix erase handling with unicode characters --- SDK/src/NDK/Widgets/RichTextAreaWidget.cpp | 4 ++-- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp b/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp index 9e5ffb84d..35abb6e06 100644 --- a/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp @@ -72,10 +72,10 @@ namespace Ndk Nz::String newText; if (firstGlyph > blockFirstGlyph) { - std::size_t characterPosition = blockText.GetCharacterPosition(firstGlyph - blockFirstGlyph - 1); + std::size_t characterPosition = blockText.GetCharacterPosition(firstGlyph - blockFirstGlyph); NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position"); - newText.Append(blockText.SubString(0, characterPosition)); + newText.Append(blockText.SubString(0, characterPosition - 1)); } if (lastGlyph < textLength) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 6860a5139..b3068d0a3 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -74,10 +74,10 @@ namespace Ndk Nz::String newText; if (firstGlyph > 0) { - std::size_t characterPosition = m_text.GetCharacterPosition(firstGlyph - 1); + std::size_t characterPosition = m_text.GetCharacterPosition(firstGlyph); NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position"); - newText.Append(m_text.SubString(0, characterPosition)); + newText.Append(m_text.SubString(0, characterPosition - 1)); } if (lastGlyph < textLength)