Fixed "Remove text for HI" issue reagarding colons - thx Boulder08 :)

Fix #2098
This commit is contained in:
Nikolaj Olsson 2016-11-20 19:11:15 +01:00
parent 1df438a6b0
commit 73daa1d1a1
2 changed files with 25 additions and 1 deletions

View File

@ -102,7 +102,8 @@ namespace Nikse.SubtitleEdit.Core.Forms
foreach (string line in lines)
{
int indexOfColon = line.IndexOf(':');
if (indexOfColon <= 0 || IsInsideBrackets(line, indexOfColon))
bool isLastColon = count == lines.Length - 1 && !HtmlUtil.RemoveHtmlTags(line).TrimEnd(':').Contains(':');
if (indexOfColon <= 0 || IsInsideBrackets(line, indexOfColon) || (isLastColon && Utilities.CountTagInText(HtmlUtil.RemoveHtmlTags(line), ' ') > 1))
{
newText = (newText + Environment.NewLine + line).Trim();

View File

@ -1576,6 +1576,29 @@ namespace Test.Logic.Forms
Assert.AreEqual("Ferguson, Kaz...", actual);
}
[TestMethod]
public void RemoveFirstLineOfTwoColons1()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBetweenSquares = true;
target.Settings.RemoveInterjections = false;
target.Settings.RemoveTextBetweenCustomTags = false;
string actual = target.RemoveTextFromHearImpaired("KIRK:" + Environment.NewLine + "<i>Captain's log, stardate 1514. 1:</i>");
Assert.AreEqual("<i>Captain's log, stardate 1514. 1:</i>", actual);
}
[TestMethod]
public void RemoveFirstLineOfTwoColons2()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBetweenSquares = true;
target.Settings.RemoveInterjections = false;
target.Settings.RemoveTextBetweenCustomTags = false;
string actual = target.RemoveTextFromHearImpaired("KIRK:" + Environment.NewLine + "Captain's log, stardate 1514. 1:");
Assert.AreEqual("Captain's log, stardate 1514. 1:", actual);
}
#region Additional test attributes
//