phdesign.NppToolBucket.FindAndReplace.Replace C# (CSharp) Method

Replace() private method

private Replace ( string findText, string replaceText ) : int
findText string
replaceText string
return int
        private int Replace(string findText, string replaceText)
        {
            // Check that the highlighted text is a match, if so replace it.
            var sel = _editor.GetSelectionRange();
            SetSearchFlags();
            var posFound = _editor.FindInTarget(findText, sel.cpMin, sel.cpMax);
            if (posFound != -1)
            {
                var match = _editor.GetTargetRange();
                if (sel.cpMin == match.cpMin && sel.cpMax == match.cpMax)
                {
                    var replacedLength = _editor.ReplaceText(replaceText, Settings.UseRegularExpression);
                    _editor.SetSelection(sel.cpMin + replacedLength, sel.cpMin);
                    _lastMatch = null;
                }
            }
            return FindNext(findText);
        }