Fix crash in history pager

ctrl-r ctrl-s ctrl-s

Attemps to go before the beginning and asserts out. Instead refuse to
do that.

(there's some weirdness where it can reduce the pager to the first
entry if you keep pressing, which I haven't found yet, but that's better than *crashing*)
This commit is contained in:
Fabian Boehm 2024-11-14 16:36:40 +01:00
parent 7846a232a9
commit 080e40aac0

View file

@ -4716,10 +4716,12 @@ impl ReaderData {
history_pager.direction = direction; history_pager.direction = direction;
match direction { match direction {
SearchDirection::Forward => { SearchDirection::Forward => {
assert!(index > result.final_index); history_pager.can_go_backwards = true;
if index == 0 {
return;
}
history_pager.history_index_start = result.final_index; history_pager.history_index_start = result.final_index;
history_pager.history_index_end = index; history_pager.history_index_end = index;
history_pager.can_go_backwards = true;
} }
SearchDirection::Backward => { SearchDirection::Backward => {
history_pager.history_index_start = index; history_pager.history_index_start = index;