msfroh commented on code in PR #13384: URL: https://github.com/apache/lucene/pull/13384#discussion_r1643261195
########## lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/DefaultPassageFormatter.java: ########## @@ -76,10 +76,15 @@ public String format(Passage[] passages, String content) { int end = passage.getMatchEnds()[i]; assert end > start; - // its possible to have overlapping terms. - // Look ahead to expand 'end' past all overlapping: + // It's possible to have overlapping terms. + // Look ahead to expand 'end' past all overlapping. + // Only take new end if it is larger than current end. while (i + 1 < passage.getNumMatches() && passage.getMatchStarts()[i + 1] < end) { - end = passage.getMatchEnds()[++i]; + if (passage.getMatchEnds()[i + 1] > end) { + end = passage.getMatchEnds()[++i]; + } else { + i++; + } Review Comment: Would it make sense to say: ``` end = Math.max(end, passage.getMatchEnds()[++i]); ``` That is, you want to pick up the new end if it's bigger, otherwise keep the existing `end`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org