mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix saturation bug in index computation code
This commit is contained in:
parent
f6aa07c20f
commit
942a64ea3b
1 changed files with 3 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue