From 080e40aac0fa91975d58f144934ec4057036755f Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 14 Nov 2024 16:36:40 +0100 Subject: [PATCH] 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*) --- src/reader.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 93c56d2c0..76513b933 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4716,10 +4716,12 @@ impl ReaderData { history_pager.direction = direction; match direction { 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_end = index; - history_pager.can_go_backwards = true; } SearchDirection::Backward => { history_pager.history_index_start = index;