Fix save-as issue after translate selected lines - thx OmrSi :)

Related to #5429
This commit is contained in:
niksedk 2021-11-06 09:56:34 +01:00
parent 56bdf9ac42
commit 05391d4ca4

View File

@ -23702,11 +23702,15 @@ namespace Nikse.SubtitleEdit.Forms
f.LoadSubtitle(s, lines, null);
// we only update selected lines
int i = 0;
foreach (int index in SubtitleListview1.SelectedIndices)
{
_subtitle.Paragraphs[index] = s.Paragraphs[i];
i++;
var currentP = _subtitle.Paragraphs[index];
var translatedP = s.Paragraphs.FirstOrDefault(p => Math.Abs(p.StartTime.TotalMilliseconds - currentP.StartTime.TotalMilliseconds) < 0.001 &&
Math.Abs(p.EndTime.TotalMilliseconds - currentP.EndTime.TotalMilliseconds) < 0.001);
if (translatedP != null)
{
currentP.Text = translatedP.Text;
}
}
UpdateSourceView();
@ -31724,10 +31728,11 @@ namespace Nikse.SubtitleEdit.Forms
{
ResetHistory();
_fileName = translateDialog.GetFileNameWithTargetLanguage(oldFileName, VideoFileName, _subtitleOriginal, GetCurrentSubtitleFormat());
_converted = true;
}
RestoreSubtitleListviewIndices();
_converted = true;
SetTitle();
SetEncoding(Encoding.UTF8);
if (!isOriginalVisible)