previous method
Looks for the previous current pattern.
start
: If null the whole line is inspected. Otherwise the search
starts at this index
Returns null if not found or the index of the hit.
Implementation
@override
int? previous(String line, [int? start]) {
final it = regExp.allMatches(line);
RegExpMatch? lastMatch;
if (it.isNotEmpty) {
if (start == null) {
lastMatch = it.last;
} else {
final bound = start + 1;
for (var match in it) {
if (match.end <= bound) {
lastMatch = match;
}
}
}
}
searchEngine.lastMatch.type = LastMatchType.regularExpr;
searchEngine.lastMatch.regExpMatch = lastMatch;
searchEngine.lastMatch.position.column = lastMatch?.start ?? -1;
return lastMatch?.start;
}