public bool SearchReplace (string withPattern, bool setSelection)
{
bool result = false;
if (IsSomethingSelected) {
var selection = MainSelection.GetSelectionRange (this);
SearchResult match = searchEngine.GetMatchAt (selection.Offset, selection.Length);
if (match != null) {
searchEngine.Replace (match, withPattern);
ClearSelection ();
Caret.Offset = selection.Offset + withPattern.Length;
result = true;
}
}
return FindNext (setSelection) != null || result;
}