mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Fixed auto-br issue when split was made at a blank at "max length+1" - thx XhmikosR (fixes some of #279)
This commit is contained in:
parent
f6c7dc2a30
commit
d8c77b07d4
@ -616,7 +616,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
// try to find " - " with uppercase letter after (dialog)
|
||||
if (splitPos == -1 && s.Contains(" - "))
|
||||
{
|
||||
for (int j = 0; j < (maximumLength / 2) + 5; j++)
|
||||
for (int j = 0; j <= (maximumLength / 2) + 5; j++)
|
||||
{
|
||||
if (mid + j + 4 < s.Length)
|
||||
{
|
||||
@ -648,6 +648,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
|
||||
if (splitPos == maximumLength + 1 && s[maximumLength] != ' ') // only allow space for last char (as it does not count)
|
||||
splitPos = -1;
|
||||
|
||||
if (splitPos == -1)
|
||||
{
|
||||
for (int j = 0; j < 15; j++)
|
||||
@ -676,9 +679,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
|
||||
if (splitPos > maximumLength) // too long first line
|
||||
splitPos = -1;
|
||||
{
|
||||
if (splitPos != maximumLength + 1 || s[maximumLength] != ' ') // allow for maxlength+1 char to be space (does not count)
|
||||
splitPos = -1;
|
||||
}
|
||||
else if (splitPos >= 0 && s.Length - splitPos > maximumLength) // too long second line
|
||||
{
|
||||
splitPos = -1;
|
||||
}
|
||||
|
||||
if (splitPos == -1)
|
||||
{
|
||||
|
@ -34,6 +34,28 @@ namespace Test
|
||||
Assert.AreEqual(s1, s2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void AutoBreakLine4()
|
||||
{
|
||||
Configuration.Settings.General.SubtitleLineMaximumLength = 43;
|
||||
string s1 = "- Seriously, though. Are you being bullied? - Nope.";
|
||||
string s2 = Utilities.AutoBreakLine(s1);
|
||||
string target = "- Seriously, though. Are you being bullied?" + Environment.NewLine + "- Nope.";
|
||||
Assert.AreEqual(target, s2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void AutoBreakLine5DoNoBreakAtPeriod()
|
||||
{
|
||||
Configuration.Settings.General.SubtitleLineMaximumLength = 43;
|
||||
string s1 = "Oh, snap, we're still saying the same thing. This is amazing!";
|
||||
string s2 = Utilities.AutoBreakLine(s1);
|
||||
string target = "Oh, snap, we're still saying the" + Environment.NewLine + "same thing. This is amazing!";
|
||||
Assert.AreEqual(target, s2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void AutoBreakLineDialog1()
|
||||
|
Loading…
Reference in New Issue
Block a user