mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 13:12:39 +01:00
Fix crash in split lines - thx Papai :)
This commit is contained in:
parent
4d6fa0bcbf
commit
3580b5b3fb
@ -353,13 +353,13 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
}
|
||||
|
||||
var words = s.Split(' ');
|
||||
for (int numberOfLines = 3; numberOfLines < 9999; numberOfLines++)
|
||||
for (var numberOfLines = 3; numberOfLines < 9999; numberOfLines++)
|
||||
{
|
||||
int average = s.Length / numberOfLines + 1;
|
||||
for (int len = average; len < maximumLength; len++)
|
||||
var average = s.Length / numberOfLines + 1;
|
||||
for (var len = average; len < maximumLength; len++)
|
||||
{
|
||||
List<int> list = SplitToX(words, numberOfLines, len);
|
||||
bool allOk = true;
|
||||
var list = SplitToX(words, numberOfLines, len);
|
||||
var allOk = true;
|
||||
foreach (var lineLength in list)
|
||||
{
|
||||
if (lineLength > maximumLength)
|
||||
@ -367,14 +367,33 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
allOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allOk)
|
||||
{
|
||||
int index = 0;
|
||||
var index = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
index += item;
|
||||
htmlTags.Add(index, Environment.NewLine);
|
||||
if (htmlTags.ContainsKey(index))
|
||||
{
|
||||
var v = htmlTags[index];
|
||||
if (v.StartsWith("</", StringComparison.Ordinal))
|
||||
{
|
||||
v = Environment.NewLine + v;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = v + Environment.NewLine;
|
||||
}
|
||||
|
||||
htmlTags[index] = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlTags.Add(index, Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
return ReInsertHtmlTagsAndCleanUp(s, htmlTags);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user