diff --git a/sources/Text/FormattedStrings/FormattingCommandsSequence.uc b/sources/Text/FormattedStrings/FormattingCommandsSequence.uc index 6d2a23e..e269e63 100644 --- a/sources/Text/FormattedStrings/FormattingCommandsSequence.uc +++ b/sources/Text/FormattedStrings/FormattingCommandsSequence.uc @@ -244,8 +244,9 @@ private final function BuildSelf() currentContents[currentContents.length] = nextCharacter; characterCounter += 1; } - // Only put in empty command if there is nothing else - if (currentContents.length > 0 || commandSequence.length == 0) + // Only put in empty command if it is push command or there is nothing else + if ( currentCommand.type == FST_StackPush + || currentContents.length > 0 || commandSequence.length == 0) { currentCommand.contents = currentContents; commandSequence[commandSequence.length] = currentCommand; diff --git a/sources/Text/Tests/TEST_FormattedStrings.uc b/sources/Text/Tests/TEST_FormattedStrings.uc index 4b3569e..bfd69f4 100644 --- a/sources/Text/Tests/TEST_FormattedStrings.uc +++ b/sources/Text/Tests/TEST_FormattedStrings.uc @@ -373,6 +373,7 @@ protected static function Test_Errors() SubTest_ErrorBadColor(); SubTest_ErrorBadShortColorTag(); SubTest_ErrorBadGradientPoint(); + SubTest_ErrorBadGradientPointEmptyBlock(); SubTest_AllErrors(); } @@ -511,6 +512,18 @@ protected static function SubTest_ErrorBadGradientPoint() TEST_ExpectTrue(errors[2].cause.ToString() == "3c"); } +protected static function SubTest_ErrorBadGradientPointEmptyBlock() +{ + local array errors; + Issue("Bad gradient point with empty text block is not reported."); + errors = class'FormattingStringParser'.static.ParseFormatted( + P("{$red$red}"),, true); + TEST_ExpectTrue(errors.length == 1); + TEST_ExpectTrue(errors[0].type == FSE_BadGradientPoint); + TEST_ExpectTrue(errors[0].cause.ToString() == "$red}"); + TEST_ExpectTrue(errors[0].count == 0); +} + protected static function SubTest_AllErrors() { local int i;