Fixed bug in "Remove text for HI" regarding trailing -/./?/! after interjection removal - thx Thunderbolt8 :)

This commit is contained in:
niksedk 2015-03-09 20:32:11 +01:00
parent a41593c6d6
commit da48c89aa1
2 changed files with 60 additions and 0 deletions

View File

@ -841,6 +841,24 @@ namespace Nikse.SubtitleEdit.Logic.Forms
return lines[0];
}
}
if (lines.Length == 2 && lines[1].Replace(".", string.Empty).Replace("?", string.Empty).Replace("!", string.Empty).Replace("-", string.Empty).Replace("—", string.Empty).Trim().Length == 0)
{
text = lines[0];
lines = text.SplitToLines();
}
else if (lines.Length == 2 && lines[0].Replace(".", string.Empty).Replace("?", string.Empty).Replace("!", string.Empty).Replace("-", string.Empty).Replace("—", string.Empty).Trim().Length == 0)
{
text = lines[1];
lines = text.SplitToLines();
}
if (text != oldText && lines.Length == 1 && Utilities.GetNumberOfLines(oldText) == 2)
{
if (oldText.StartsWith("-") &&
(oldText.Contains("." + Environment.NewLine) || oldText.Contains("!" + Environment.NewLine) || oldText.Contains("?" + Environment.NewLine)))
{
text = text.TrimStart('-').TrimStart();
}
}
return text;
}

View File

@ -1056,6 +1056,48 @@ namespace Test
Assert.AreEqual(expected, actual);
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveTextDontLeaveDoubleDash()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBetweenCustomTags = false;
target.Settings.RemoveInterjections = true;
string text = "- Mr. Harding?" + Environment.NewLine + "Uh--";
const string expected = "Mr. Harding?";
string actual = target.RemoveTextFromHearImpaired(text);
Assert.AreEqual(expected, actual);
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveTextDontLeaveDot()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBetweenCustomTags = false;
target.Settings.RemoveInterjections = true;
string text = "- Mr. Harding?" + Environment.NewLine + "- Mm-hm. Oh.";
const string expected = "Mr. Harding?";
string actual = target.RemoveTextFromHearImpaired(text);
Assert.AreEqual(expected, actual);
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveTextDontLeaveExl()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBetweenCustomTags = false;
target.Settings.RemoveInterjections = true;
string text = "-Sit down. Sit down." + Environment.NewLine + "-Oh! Oh!";
const string expected = "Sit down. Sit down.";
string actual = target.RemoveTextFromHearImpaired(text);
Assert.AreEqual(expected, actual);
}
#region Additional test attributes
//