setHighlights method
Sets ranges of characters to highlight.
For instance, [[2, 10], [20, 30]] will highlight characters
2 to 10 and 20 to 30.
Note that highlights are not expected to transpose each other, and are also
expected to be in order.
Implementation
ViewportModel setHighlights(List<List<int>> matches) {
if (matches.isEmpty || _lines.isEmpty) {
return copyWith(highlights: []);
}
final highlights = _parseMatches(_originalLines.join('\n'), matches);
final newModel = copyWith(highlights: highlights);
return newModel
.copyWith(currentHighlightIndex: newModel._findNearestMatch())
._showHighlight();
}