From 05391d4ca4926e27b5fbd869ff9dc9232b0d155f Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 6 Nov 2021 09:56:34 +0100 Subject: [PATCH] Fix save-as issue after translate selected lines - thx OmrSi :) Related to #5429 --- src/ui/Forms/Main.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index ce238c5c9..aae667705 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -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)