Fix search highlight in multi-whitespace bodies.

The way the highlight was done could get screwed up if you had multiple
whitespaces in a row. This particularly came up with messages with
multiple newlines.
This commit is contained in:
Greyson Parrelli
2019-02-28 11:55:12 -08:00
parent 42e94d8f92
commit 7fd6f5b3ff
2 changed files with 27 additions and 11 deletions

View File

@@ -23,6 +23,15 @@ public class SearchUtilTest {
assertEquals(Arrays.asList(new Pair<>(0, 1)), result);
}
@Test
public void getHighlightRanges_singleHighlightTokenWithNewLines() {
String text = "123\n\n\nabc";
String highlight = "a";
List<Pair<Integer, Integer>> result = SearchUtil.getHighlightRanges(LOCALE, text, highlight);
assertEquals(Arrays.asList(new Pair<>(6, 7)), result);
}
@Test
public void getHighlightRanges_multipleHighlightTokens() {
String text = "a bc";