From 5c6400c5635362ccbb39e0324a4681d4029d3f74 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 10 Dec 2021 23:01:49 -0500 Subject: fix some scrolling edge cases --- src/readline.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/readline.rs') diff --git a/src/readline.rs b/src/readline.rs index d396d3d..37c466f 100644 --- a/src/readline.rs +++ b/src/readline.rs @@ -19,6 +19,7 @@ impl Readline { pub async fn handle_key( &mut self, key: textmode::Key, + history_size: usize, ) -> Option { match key { textmode::Key::String(s) => self.add_input(&s), @@ -42,9 +43,13 @@ impl Readline { textmode::Key::Left => self.cursor_left(), textmode::Key::Right => self.cursor_right(), textmode::Key::Up => { - return Some(crate::action::Action::UpdateFocus( - crate::action::Focus::Scrolling(Some(usize::MAX)), - )) + if history_size > 0 { + return Some(crate::action::Action::UpdateFocus( + crate::action::Focus::Scrolling(Some( + history_size - 1, + )), + )); + } } _ => {} } -- cgit v1.2.3-54-g00ecf