Fix hang in "FCE Remove unneeded spaces" - thx Zoltán :)

Just in time for #4131 :)
This commit is contained in:
Nikolaj Olsson 2020-04-27 18:53:03 +02:00
parent 44cafe557f
commit ff7c17ecb5
2 changed files with 48 additions and 2 deletions

View File

@ -2093,7 +2093,7 @@ namespace Nikse.SubtitleEdit.Core
while (text.Contains(" ?</i>" + Environment.NewLine))
{
text = text.Replace(" !</i>" + Environment.NewLine, "!</i>" + Environment.NewLine);
text = text.Replace(" ?</i>" + Environment.NewLine, "?</i>" + Environment.NewLine);
}
if (text.StartsWith("- ... ", StringComparison.Ordinal))

View File

@ -1156,7 +1156,7 @@ namespace Test.FixCommonErrors
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag()
public void FixUnneededSpacesBeforeEndTag1()
{
using (var target = GetFixCommonErrorsLib())
{
@ -1166,6 +1166,30 @@ namespace Test.FixCommonErrors
}
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag1b()
{
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>I happen to have" + Environment.NewLine + " the blood of an ancient family !</i>");
new FixUnneededSpaces().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual("<i>I happen to have" + Environment.NewLine + "the blood of an ancient family!</i>", _subtitle.Paragraphs[0].Text);
}
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag1c()
{
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>I happen to have" + Environment.NewLine + " the blood of an ancient family ?</i>");
new FixUnneededSpaces().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual("<i>I happen to have" + Environment.NewLine + "the blood of an ancient family?</i>", _subtitle.Paragraphs[0].Text);
}
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag2()
{
@ -1177,6 +1201,28 @@ namespace Test.FixCommonErrors
}
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag2a()
{
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>I happen to have to! </i>" + Environment.NewLine + "Right?");
new FixUnneededSpaces().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual("<i>I happen to have to!</i>" + Environment.NewLine + "Right?", _subtitle.Paragraphs[0].Text);
}
}
[TestMethod]
public void FixUnneededSpacesBeforeEndTag2b()
{
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>I happen to have to? </i>" + Environment.NewLine + "Right?");
new FixUnneededSpaces().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual("<i>I happen to have to?</i>" + Environment.NewLine + "Right?", _subtitle.Paragraphs[0].Text);
}
}
#endregion Fix unneeded spaces
#region Fix EmptyLines