From 9ff02d6a7fa0904ebcd9979660b84057e1d9b1c0 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 16 Feb 2024 18:21:54 +0100 Subject: [PATCH] Fix crash in the history pager Delete the last shown entry and it'll subtract with overflow --- src/pager.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pager.rs b/src/pager.rs index 7471fb620..c46a1340b 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -827,6 +827,9 @@ impl Pager { pub fn set_selected_completion_index(&mut self, mut new_index: Option) { // Current users are off by one at most. assert!(new_index.is_none_or(|new_index| new_index <= self.completion_infos.len())); + if self.completion_infos.is_empty() { + return; + } if new_index == Some(self.completion_infos.len()) { new_index = Some(self.completion_infos.len() - 1); }