Browse Source

Fix some errors formatted text not being reported

Formatted blocks with empty contents were not being reported sometimes
when formatted text ended with them, e.g. "{$red$red}".
pull/8/head
Anton Tarasenko 2 years ago
parent
commit
03cf5c5745
  1. 5
      sources/Text/FormattedStrings/FormattingCommandsSequence.uc
  2. 13
      sources/Text/Tests/TEST_FormattedStrings.uc

5
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;

13
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<FormattingErrorsReport.FormattedStringError> 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;

Loading…
Cancel
Save