public Highlight SelectPreviousMatch() { if (CurrentMatch != null) { CurrentMatch.Deselect(); } Highlight h = PreviousMatch(); if (h != null) { ignoreFocusChange = true; h.Select(); ignoreFocusChange = false; } return(h); }
/// <summary> /// Replace the current match with <c>replacement</c> /// </summary> public void ReplaceMatch(string replacement) { int start = -replacement.Length; if (CurrentMatch != null) { //Because the replacement might cause another match, we will want to skip the next //CurrentMatch if it's within the scope of the replacement. start = CurrentMatch.AbsoluteStart; CurrentMatch.ReplaceText(Query.ProcessReplacementSyntax(replacement, CurrentMatch)); CurrentMatch.Deselect(); highlightHandlers.RemoveMatch(CurrentMatch); } SelectNextMatch(); //incase we selected in the region that we just replaced, move on while (CurrentMatch != null && !(CurrentMatch.AbsoluteEnd <= start || CurrentMatch.AbsoluteStart >= start + replacement.Length)) { SelectNextMatch(); } }