diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-11 04:36:09 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-11 04:36:09 -0500 |
commit | 7a411e269b59cb7754eadacaf29a18e02845040b (patch) | |
tree | 3e39891578f3d5991c8ea302758d1b4febbb83cd /src/history.rs | |
parent | 619cd19e91c7a1ae176a706f0e1f47887cd7a1ec (diff) | |
download | nbsh-7a411e269b59cb7754eadacaf29a18e02845040b.tar.gz nbsh-7a411e269b59cb7754eadacaf29a18e02845040b.zip |
handle the focused cursor being past the end of output
Diffstat (limited to 'src/history.rs')
-rw-r--r-- | src/history.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/history.rs b/src/history.rs index e5ad161..348224b 100644 --- a/src/history.rs +++ b/src/history.rs @@ -127,10 +127,11 @@ impl History { &self, out: &mut textmode::Output, repl_lines: usize, + focus: Option<usize>, ) -> anyhow::Result<()> { let mut used_lines = repl_lines; let mut pos = None; - for entry in self.entries.iter().rev() { + for (idx, entry) in self.entries.iter().enumerate().rev() { let entry = entry.lock_arc().await; let screen = entry.vt.screen(); let mut last_row = 0; @@ -139,6 +140,12 @@ impl History { last_row = idx + 1; } } + if focus == Some(idx) { + last_row = std::cmp::max( + last_row, + screen.cursor_position().0 as usize + 1, + ); + } used_lines += 1 + std::cmp::min(6, last_row); if used_lines > 24 { break; |