Fixed issue in "Remove text for HI" - thx Andrew :)

This commit is contained in:
Nikolaj Olsson 2016-04-04 06:39:04 +02:00
parent 20dd4cf749
commit f5211b3f81
2 changed files with 19 additions and 2 deletions

View File

@ -200,7 +200,9 @@ namespace Nikse.SubtitleEdit.Core.Forms
string l1Trimmed = HtmlUtil.RemoveHtmlTags(lines[0]).TrimEnd('"'); string l1Trimmed = HtmlUtil.RemoveHtmlTags(lines[0]).TrimEnd('"');
if (count == 1 && lines.Length == 2 && !l1Trimmed.EndsWith('.') && if (count == 1 && lines.Length == 2 && !l1Trimmed.EndsWith('.') &&
!l1Trimmed.EndsWith('!') && !l1Trimmed.EndsWith('!') &&
!l1Trimmed.EndsWith('?')) !l1Trimmed.EndsWith('?') &&
!l1Trimmed.EndsWith("--", StringComparison.Ordinal) &&
!l1Trimmed.EndsWith("—", StringComparison.Ordinal))
{ {
remove = false; remove = false;
} }
@ -343,7 +345,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
if (insertDash) if (insertDash)
{ {
string arr0QuoteTrimmed = arr[0].TrimEnd('"'); string arr0QuoteTrimmed = arr[0].TrimEnd('"');
if (arr0QuoteTrimmed.Length > 0 && !".?!".Contains(arr0QuoteTrimmed[arr0QuoteTrimmed.Length - 1]) && !arr0QuoteTrimmed.EndsWith("</i>", StringComparison.Ordinal)) if (arr0QuoteTrimmed.Length > 0 && !".?!".Contains(arr0QuoteTrimmed[arr0QuoteTrimmed.Length - 1]) && !arr0QuoteTrimmed.EndsWith("</i>", StringComparison.Ordinal) && !arr0QuoteTrimmed.EndsWith("--", StringComparison.Ordinal) && !arr0QuoteTrimmed.EndsWith("—", StringComparison.Ordinal))
{ {
if (!arr1Stripable.Pre.Contains('-')) if (!arr1Stripable.Pre.Contains('-'))
{ {

View File

@ -1554,6 +1554,21 @@ namespace Test.Logic.Forms
Assert.AreEqual(expected, actual); Assert.AreEqual(expected, actual);
} }
[TestMethod]
public void RemoveColonTestDash()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
target.Settings.RemoveIfAllUppercase = false;
target.Settings.RemoveTextBeforeColon = true;
target.Settings.OnlyIfInSeparateLine = false;
target.Settings.OnlyIfInSeparateLine = false;
target.Settings.ColonSeparateLine = false;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
string text = "- I have a theory, captain--" + Environment.NewLine + "UHURA: Captain Kirk.";
string expected = "- I have a theory, captain--" + Environment.NewLine + "- Captain Kirk."; ;
string actual = target.RemoveColon(text);
Assert.AreEqual(expected, actual);
}
#region Additional test attributes #region Additional test attributes