Fix invalid slice bounds when highlighting overlapping matches

eg. Given 'foobar' and matches for 'foo' and 'obar', avoid
trying to add the substring between the matches to the output.