Fix undo after "merge selected" for 3+ lines - thx Llorx :)

Fix #8740
This commit is contained in:
Nikolaj Olsson 2024-08-17 14:16:55 +02:00
parent 8990169dd8
commit bdd19fa34e

View File

@ -12820,8 +12820,11 @@ namespace Nikse.SubtitleEdit.Forms
private void MergeSelectedLines(BreakMode breakMode = BreakMode.Normal)
{
if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1)
if (_subtitle.Paragraphs.Count <= 0 || SubtitleListview1.SelectedItems.Count <= 1)
{
return;
}
var sb = new StringBuilder();
var deleteIndices = new List<int>();
bool first = true;
@ -12887,7 +12890,7 @@ namespace Nikse.SubtitleEdit.Forms
MakeHistoryForUndo(_language.BeforeMergeLines);
var currentParagraph = _subtitle.Paragraphs[firstIndex];
string text = sb.ToString();
string text = sb.ToString().TrimEnd();
text = HtmlUtil.FixInvalidItalicTags(text);
text = FixAssaTagsAfterMerge(text);
text = ChangeAllLinesTagsToSingleTag(text, "i");
@ -13008,7 +13011,6 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
RefreshSelectedParagraph();
}
}
private void ExtendBeforeToolStripMenuItemClick(object sender, EventArgs e)
{
@ -31472,7 +31474,7 @@ namespace Nikse.SubtitleEdit.Forms
}
string newText = p.Text.TrimEnd();
string oldText = _listViewTextUndoLast;
string oldText = _listViewTextUndoLast.TrimEnd();
if (oldText == null)
{
return;