summaryrefslogtreecommitdiffstats
path: root/src/readline.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-10 23:01:49 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-10 23:01:49 -0500
commit5c6400c5635362ccbb39e0324a4681d4029d3f74 (patch)
tree4a4166bdbffe11a315fce0b8e39f148b92180070 /src/readline.rs
parent58979a8db547a1083778951d6376a27930006cbc (diff)
downloadnbsh-5c6400c5635362ccbb39e0324a4681d4029d3f74.tar.gz
nbsh-5c6400c5635362ccbb39e0324a4681d4029d3f74.zip
fix some scrolling edge cases
Diffstat (limited to 'src/readline.rs')
-rw-r--r--src/readline.rs11
1 files changed, 8 insertions, 3 deletions
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<crate::action::Action> {
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,
+ )),
+ ));
+ }
}
_ => {}
}