Fix regression causing crash in token history search

I'm not yet sure how to reproduce 4dfcd4cb4e (reader: Check bounds
for color, 2022-08-26).  Commit 55fd43d86c (Port reader, 2023-12-22)
accidentally changed historical behavior, fix that.

Fixes #11096
This commit is contained in:
Johannes Altmanninger 2025-01-27 06:01:52 +01:00
parent fff421ad9c
commit d7354880e3

View File

@ -1618,12 +1618,13 @@ impl<'a> Reader<'a> {
// Highlight any history search.
if !self.conf.in_silent_mode && data.history_search_range.is_some() {
let mut end = data.history_search_range.unwrap().end();
if colors.len() < end {
end = colors.len();
let mut range = data.history_search_range.unwrap().as_usize();
if range.end > colors.len() {
range.start = range.start.min(colors.len());
range.end = colors.len();
}
for color in &mut colors[data.history_search_range.unwrap().start()..end] {
for color in &mut colors[range] {
color.foreground = HighlightRole::search_match;
color.background = HighlightRole::search_match;
}