replaceActiveSearchMatch method
Replaces the active match and refreshes the current search.
Implementation
bool replaceActiveSearchMatch(String replacementTemplate) {
final session = _searchSession;
final match = session?.current;
if (session == null || match == null) return false;
final matchedText = _document.textInRange(
startOffset: match.startOffset,
endOffset: match.endOffset,
);
final replacement = expandSearchReplacementTemplate(
replacementTemplate,
match,
matchedText,
);
setSelections(
TextSelectionSet([
TextSelectionRange(
startOffset: match.startOffset,
endOffset: match.endOffset,
),
], primaryOffset: match.endOffset),
);
insertString(replacement);
startSearch(session.query);
return true;
}