diff --git a/services/bao-console/src/repl.rs b/services/bao-console/src/repl.rs index 3af2a93bb..ece4d1496 100644 --- a/services/bao-console/src/repl.rs +++ b/services/bao-console/src/repl.rs @@ -56,8 +56,9 @@ impl Repl { // An index of -1 gives the most recent command. // -2 would give the second most recent command pub(crate) fn get_history(&mut self, index: isize) -> &str { - &self.history - [(self.history.len() as isize + index).max(0).min(self.history.len() as isize - 1) as usize] + &self.history[(self.history.len() as isize + index) + .max(0) + .min(self.history.len().saturating_sub(1) as isize) as usize] .text }