Fix crash related to #6829 - thx lolipopsz :)

This commit is contained in:
niksedk 2023-04-15 13:09:49 +02:00
parent 3395af7fa3
commit 87f6ed1fb0
2 changed files with 24 additions and 1 deletions

View File

@ -328,5 +328,21 @@ namespace Test.Core
var res = input.ToggleCasing();
Assert.AreEqual("how are you", res);
}
[TestMethod]
public void ToggleCasingWithFont()
{
var input = "<font color=\"Red\">HOW ARE YOU</font>";
var res = input.ToggleCasing();
Assert.AreEqual("<font color=\"Red\">how are you</font>", res);
}
[TestMethod]
public void ToggleCasingAssa()
{
var input = "{\\i1}This is an example…{\\i0}";
var res = input.ToggleCasing();
Assert.AreEqual("{\\i1}THIS IS AN EXAMPLE…{\\i0}", res);
}
}
}

View File

@ -546,7 +546,14 @@ namespace Nikse.SubtitleEdit.Core.Common
for (var index = tags.Count - 1; index >= 0; index--)
{
var keyValuePair = tags[index];
s = s.Insert(keyValuePair.Key, keyValuePair.Value);
if (keyValuePair.Key >= s.Length)
{
s += keyValuePair.Value;
}
else
{
s = s.Insert(keyValuePair.Key, keyValuePair.Value);
}
}
return s;