Fix issue w "remove text for hi" and colon/dashes - thx Сергей :)

This commit is contained in:
niksedk 2021-11-09 06:39:03 +01:00
parent e135a7c77a
commit 39557cd00f
2 changed files with 21 additions and 0 deletions

View File

@ -1707,6 +1707,16 @@ namespace Test.Logic.Forms
Assert.AreEqual("- Step out of here... Not world." + Environment.NewLine + "- It's a British record.", actual);
}
public void RemoveColonNameStartFirstLineNonDialog()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBeforeColon = true;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
target.Settings.NameList.Add("JEREMY");
string actual = target.RemoveColon("- JOE: All right." + Environment.NewLine + "Sorry about that.");
Assert.AreEqual("All right." + Environment.NewLine + "Sorry about that.", actual);
}
[TestMethod]
public void RemoveNameAndCustom()
{

View File

@ -105,6 +105,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
int count = 0;
bool removedInFirstLine = false;
bool removedInSecondLine = false;
bool removedFirstLineNotStart = false;
foreach (string line in lines)
{
int indexOfColon = line.IndexOf(':');
@ -262,6 +263,10 @@ namespace Nikse.SubtitleEdit.Core.Forms
if (remove)
{
newText = RemovePartialBeforeColon(line, indexOfColon, newText, count, ref removedInFirstLine, ref removedInSecondLine, ref remove);
if (count == 0 && removedInFirstLine && indexOfColon > 10)
{
removedFirstLineNotStart = true;
}
if (remove)
{
@ -520,6 +525,12 @@ namespace Nikse.SubtitleEdit.Core.Forms
insertDash = false;
}
}
if (insertDash && removedInFirstLine && !removedInSecondLine && !removedFirstLineNotStart &&
!HtmlUtil.RemoveHtmlTags(arr[1], true).StartsWith("-"))
{
insertDash = false;
}
}
if (insertDash)