Fix minor "remove text for hi" issue - thx taxen :)

Fix #4953
This commit is contained in:
Nikolaj Olsson 2021-04-06 12:18:58 +02:00
parent c52a279300
commit 2aba793f53
2 changed files with 44 additions and 0 deletions

View File

@ -1959,6 +1959,32 @@ namespace Test.Logic.Forms
Assert.AreEqual("<i>- and many were imm..." + Environment.NewLine + "- We believe" + Environment.NewLine + "the future of food...</i>", actual);
}
[TestMethod]
public void RemoveTextForHiSecondDialogEmpty()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBeforeColon = true;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
target.Settings.RemoveInterjections = false;
target.Settings.RemoveTextBetweenBrackets = false;
target.Settings.OnlyIfInSeparateLine = false;
string actual = target.RemoveTextFromHearImpaired("- Oh. No." + Environment.NewLine + "-");
Assert.AreEqual("Oh. No.", actual);
}
[TestMethod]
public void RemoveTextForHiFirstDialogEmpty()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBeforeColon = true;
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
target.Settings.RemoveInterjections = false;
target.Settings.RemoveTextBetweenBrackets = false;
target.Settings.OnlyIfInSeparateLine = false;
string actual = target.RemoveTextFromHearImpaired("-" + Environment.NewLine + "- Oh. No.");
Assert.AreEqual("Oh. No.", actual);
}
[TestMethod]
public void RemoveInterjectionsAfterComma()
{

View File

@ -833,6 +833,24 @@ namespace Nikse.SubtitleEdit.Core.Forms
pre = pre.Replace(Settings.CustomStart, string.Empty);
post = post.Replace(Settings.CustomEnd, string.Empty);
}
// fix empty ending dialog line "-"
var inputLines = text.SplitToLines();
if (inputLines.Count == 2)
{
if (inputLines[0].HasSentenceEnding() && inputLines[1] == "-")
{
text = inputLines[0].TrimStart('-').TrimStart();
}
}
else if (inputLines.Count == 3)
{
if (inputLines[1].HasSentenceEnding() && inputLines[2] == "-")
{
text = inputLines[0] + Environment.NewLine + inputLines[1];
}
}
var st = new StrippableText(text, pre, post);
var sb = new StringBuilder();
var parts = st.StrippedText.Trim().SplitToLines();