Fix text formatting infinite loop

#1127
This commit is contained in:
Wojtek Figat
2023-05-28 16:55:47 +02:00
parent 587578ccfb
commit f3393c46a5

View File

@@ -178,7 +178,8 @@ void Font::ProcessText(const StringView& text, Array<FontLineCache>& outputLines
if (lastWrapCharIndex != INVALID_INDEX)
{
// Skip moving twice for the same character
if (outputLines.HasItems() && outputLines.Last().LastCharIndex == lastWrapCharIndex - 1)
int32 lastLineLasCharIndex = outputLines.HasItems() ? outputLines.Last().LastCharIndex : -10000;
if (lastLineLasCharIndex == lastWrapCharIndex || lastLineLasCharIndex == lastWrapCharIndex - 1 || lastLineLasCharIndex == lastWrapCharIndex - 2)
{
currentIndex = nextCharIndex;
lastMoveLine = moveLine;