diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 6487b8c34..b9cbf7456 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -2783,7 +2783,7 @@ namespace Nikse.SubtitleEdit.Forms int selectedIndex = -1; if (SubtitleListview1.SelectedItems.Count > 0) selectedIndex = SubtitleListview1.SelectedItems[0].Index; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex+1)); @@ -2989,12 +2989,21 @@ namespace Nikse.SubtitleEdit.Forms if (replaceDialog.ReplaceAll) { - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); - textBoxListViewText.SelectionStart = _findHelper.SelectedPosition; - textBoxListViewText.SelectionLength = _findHelper.FindTextLength; - textBoxListViewText.SelectedText = _findHelper.ReplaceText; + if (_findHelper.MatchInOriginal) + { + textBoxListViewTextAlternate.SelectionStart = _findHelper.SelectedPosition; + textBoxListViewTextAlternate.SelectionLength = _findHelper.FindTextLength; + textBoxListViewTextAlternate.SelectedText = _findHelper.ReplaceText; + } + else + { + textBoxListViewText.SelectionStart = _findHelper.SelectedPosition; + textBoxListViewText.SelectionLength = _findHelper.FindTextLength; + textBoxListViewText.SelectedText = _findHelper.ReplaceText; + } _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; searchStringFound = true; replaceCount++; @@ -3013,7 +3022,7 @@ namespace Nikse.SubtitleEdit.Forms _findHelper.SelectedIndex = 0; _findHelper.SelectedPosition = 0; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); textBoxListViewText.SelectionStart = _findHelper.SelectedPosition; @@ -3029,7 +3038,7 @@ namespace Nikse.SubtitleEdit.Forms } else if (replaceDialog.FindOnly) { - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); textBoxListViewText.Focus(); @@ -3049,7 +3058,7 @@ namespace Nikse.SubtitleEdit.Forms _findHelper.StartLineIndex = 0; _findHelper.SelectedIndex = 0; _findHelper.SelectedPosition = 0; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); textBoxListViewText.Focus(); @@ -3082,12 +3091,21 @@ namespace Nikse.SubtitleEdit.Forms msg = _language.OneReplacementMade + " "; } - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); - textBoxListViewText.Focus(); - textBoxListViewText.SelectionStart = _findHelper.SelectedPosition; - textBoxListViewText.SelectionLength = _findHelper.FindTextLength; + if (_findHelper.MatchInOriginal) + { + textBoxListViewTextAlternate.Focus(); + textBoxListViewTextAlternate.SelectionStart = _findHelper.SelectedPosition; + textBoxListViewTextAlternate.SelectionLength = _findHelper.FindTextLength; + } + else + { + textBoxListViewText.Focus(); + textBoxListViewText.SelectionStart = _findHelper.SelectedPosition; + textBoxListViewText.SelectionLength = _findHelper.FindTextLength; + } _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY + _language.XFoundAtLineNumberY, _findHelper.SelectedIndex + 1, _findHelper.FindText)); } @@ -3107,7 +3125,7 @@ namespace Nikse.SubtitleEdit.Forms _findHelper.SelectedPosition = 0; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition)) + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) { SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex); textBoxListViewText.Focus(); diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index e2b3c522d..05043995c 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -681,7 +681,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAegBDgHoAQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAfABDgHwAQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/Logic/FindReplaceDialogHelper.cs b/src/Logic/FindReplaceDialogHelper.cs index ed19c0c47..2f5627ad7 100644 --- a/src/Logic/FindReplaceDialogHelper.cs +++ b/src/Logic/FindReplaceDialogHelper.cs @@ -58,7 +58,7 @@ namespace Nikse.SubtitleEdit.Logic public bool Find(Subtitle subtitle, Subtitle originalSubtitle, int startIndex) { - return FindNext(subtitle, originalSubtitle, startIndex, 0); + return FindNext(subtitle, originalSubtitle, startIndex, 0, Configuration.Settings.General.AllowEditOfOriginalSubtitle); } public bool Find(TextBox textBox, int startIndex) @@ -97,7 +97,7 @@ namespace Nikse.SubtitleEdit.Logic return -1; } - public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position) + public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle) { Success = false; int index = 0; @@ -123,7 +123,7 @@ namespace Nikse.SubtitleEdit.Logic } MatchInOriginal = false; - if (originalSubtitle != null) + if (originalSubtitle != null && allowEditOfOriginalSubtitle) { Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs); if (o != null)