Merge pull request #588 from ivandrofly/bugfix/patch

Bugfix/patch
This commit is contained in:
Nikolaj Olsson 2015-02-28 10:25:32 +01:00
commit ecb3caac69
3 changed files with 25 additions and 13 deletions

View File

@ -451,14 +451,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms
{
s = s.TrimEnd().TrimEnd('.', '?', '!', ':', ';');
s = s.TrimStart('-');
if (!s.Contains('.') &&
!s.Contains('?') &&
!s.Contains('!') &&
!s.Contains(':') &&
!s.Contains(';') &&
!s.Contains('-') &&
!s.Contains('♪') &&
!s.Contains('♫') &&
if (s.IndexOfAny(new[] { '.', '?', '!', ':', ';', '-', '♪', '♫' }) < 0 &&
!(s.StartsWith('[') && s.Contains("]" + Environment.NewLine, StringComparison.Ordinal)) &&
!(s.StartsWith('(') && s.Contains(")" + Environment.NewLine, StringComparison.Ordinal)) &&
s != s.ToUpper())
@ -470,4 +463,4 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
}
}
}

View File

@ -106,8 +106,8 @@ namespace Nikse.SubtitleEdit.Logic.Forms
else
{
var st = new StripableText(pre);
if (count == 1 && Utilities.GetNumberOfLines(text) == 2 && removedInFirstLine && Utilities.CountTagInText(line, ':') == 1 &&
".?!".IndexOf(newText[newText.Length - 1]) < 0 && ".</i>!</i>?</i>".IndexOf(newText.Substring(newText.Length - ".</i>".Length), StringComparison.Ordinal) < 0 &&
if (count == 1 && newText.Length > 1 && removedInFirstLine && Utilities.CountTagInText(line, ':') == 1 &&
".?!".IndexOf(newText[newText.Length - 1]) < 0 && newText.LineEndsWithHtmlTag(true) &&
line != line.ToUpper())
{
if (pre.Contains("<i>") && line.Contains("</i>"))
@ -123,8 +123,8 @@ namespace Nikse.SubtitleEdit.Logic.Forms
else
newText = newText + Environment.NewLine + line;
}
else if (count == 1 && Utilities.GetNumberOfLines(text) == 2 && indexOfColon > 15 && line.Substring(0, indexOfColon).Contains(' ') && Utilities.CountTagInText(line, ':') == 1 &&
".?!".IndexOf(newText[newText.Length - 1]) < 0 && ".</i>!</i>?</i>".IndexOf(newText.Substring(newText.Length - ".</i>".Length), StringComparison.Ordinal) < 0 &&
else if (count == 1 && newText.Length > 1 && indexOfColon > 15 && line.Substring(0, indexOfColon).Contains(' ') && Utilities.CountTagInText(line, ':') == 1 &&
".?!".IndexOf(newText[newText.Length - 1]) < 0 && newText.LineEndsWithHtmlTag(true) &&
line != line.ToUpper())
{
if (pre.Contains("<i>") && line.Contains("</i>"))

View File

@ -764,6 +764,25 @@ namespace Test
Assert.AreEqual(expected, actual);
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveTextBeforeColonTest1()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
target.Settings.RemoveIfAllUppercase = false;
target.Settings.RemoveInterjections = false;
target.Settings.RemoveTextBeforeColon = false;
target.Settings.OnlyIfInSeparateLine = false;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
target.Settings.ColonSeparateLine = false;
target.Settings.RemoveTextBetweenParentheses = true;
target.Settings.RemoveTextBeforeColon = true;
const string text = "SKOTT AVFYRADE: 760\r\nFORDON FÖRSTÖRDA: 12";
const string expected = "760\r\n12";
string actual = target.RemoveColon(text);
Assert.AreEqual(expected, actual);
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveTextRemoveDashBeforeSquareBrackets()