mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Fixed bug in "Remove text for HI" regarding trailing -/./?/! after interjection removal - thx Thunderbolt8 :)
This commit is contained in:
parent
a41593c6d6
commit
da48c89aa1
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user