mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Fix for second regex search/replace - thx OmrSi :)
This commit is contained in:
parent
dbb30ff87d
commit
9a1c247e2d
@ -157,7 +157,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFind(FindText, FindReplaceType);
|
||||
_findAndReplaceMethods.FindDialogFind(FindText, FindReplaceType, _regEx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6333,7 +6333,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FindPrevious();
|
||||
}
|
||||
|
||||
public void FindDialogFind(string findText, ReplaceType findReplaceType)
|
||||
public void FindDialogFind(string findText, ReplaceType findReplaceType, Regex regex)
|
||||
{
|
||||
_findHelper = _findHelper ?? _findDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
||||
_findHelper.FindText = findText;
|
||||
@ -6341,6 +6341,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_findHelper.FindReplaceType = findReplaceType;
|
||||
if (findReplaceType.FindType == FindType.RegEx)
|
||||
{
|
||||
_findHelper.SetRegex(regex);
|
||||
}
|
||||
|
||||
DialogFind(_findHelper);
|
||||
|
@ -9790,13 +9790,14 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
Configuration.Settings.Tools.OcrGoogleCloudVisionSeHandlesTextMerge = checkBoxSeHandlesTextMerge.Checked;
|
||||
}
|
||||
|
||||
public void FindDialogFind(string findText, ReplaceType findReplaceType)
|
||||
public void FindDialogFind(string findText, ReplaceType findReplaceType, Regex regex)
|
||||
{
|
||||
_findHelper = _findHelper ?? _findDialog.GetFindDialogHelper(_selectedIndex);
|
||||
_findHelper.FindText = findText;
|
||||
_findHelper.FindTextLength = findText.Length;
|
||||
_findHelper.FindReplaceType = findReplaceType;
|
||||
_findHelper.InProgress = true;
|
||||
_findHelper.SetRegex(regex);
|
||||
if (!string.IsNullOrWhiteSpace(_findHelper.FindText))
|
||||
{
|
||||
if (Configuration.Settings.Tools.FindHistory.Count == 0 || Configuration.Settings.Tools.FindHistory[0] != _findHelper.FindText)
|
||||
|
@ -181,6 +181,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
ReplaceAll = false;
|
||||
FindOnly = false;
|
||||
SetRegEx();
|
||||
|
||||
Validate(FindText);
|
||||
if (DialogResult == DialogResult.OK)
|
||||
@ -190,7 +191,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
buttonReplace.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void ButtonReplaceAllClick(object sender, EventArgs e)
|
||||
@ -198,6 +198,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ReplaceAll = true;
|
||||
FindOnly = false;
|
||||
|
||||
SetRegEx();
|
||||
Validate(FindText);
|
||||
if (DialogResult == DialogResult.OK)
|
||||
{
|
||||
@ -206,7 +207,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
buttonReplaceAll.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void Validate(string searchText)
|
||||
@ -242,9 +242,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ButtonFindClick(object sender, EventArgs e)
|
||||
{
|
||||
SetRegEx();
|
||||
Find();
|
||||
buttonFind.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void SetRegEx()
|
||||
@ -304,6 +304,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_findHelper.FindReplaceType = GetFindType();
|
||||
_findHelper.FindText = FindText;
|
||||
_findHelper.FindTextLength = _findHelper.FindText.Length;
|
||||
_findHelper.SetRegex(_regEx);
|
||||
}
|
||||
|
||||
private void RadioButtonCheckedChanged(object sender, EventArgs e)
|
||||
|
@ -500,5 +500,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
private StringComparison GetComparison() => FindReplaceType.FindType == FindType.Normal ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
|
||||
|
||||
public void SetRegex(Regex regex)
|
||||
{
|
||||
_regEx = regex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
using Nikse.SubtitleEdit.Core.Enums;
|
||||
using System.Text.RegularExpressions;
|
||||
using Nikse.SubtitleEdit.Core.Enums;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
public interface IFindAndReplace
|
||||
{
|
||||
void FindDialogFind(string findText, ReplaceType findReplaceType);
|
||||
void FindDialogFind(string findText, ReplaceType findReplaceType, Regex regex);
|
||||
void FindDialogFindPrevious(string findText);
|
||||
void FindDialogClose();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user