summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-11 04:36:09 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-11 04:36:09 -0500
commit7a411e269b59cb7754eadacaf29a18e02845040b (patch)
tree3e39891578f3d5991c8ea302758d1b4febbb83cd /src/state.rs
parent619cd19e91c7a1ae176a706f0e1f47887cd7a1ec (diff)
downloadnbsh-7a411e269b59cb7754eadacaf29a18e02845040b.tar.gz
nbsh-7a411e269b59cb7754eadacaf29a18e02845040b.zip
handle the focused cursor being past the end of output
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/state.rs b/src/state.rs
index 5a1e1bd..854c306 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -25,13 +25,16 @@ impl State {
pub async fn render(&mut self) -> anyhow::Result<()> {
self.output.clear();
- if let Focus::Readline = self.focus {
- self.history
- .render(&mut self.output, self.readline.lines())
- .await?;
- self.readline.render(&mut self.output).await?;
- } else {
- self.history.render(&mut self.output, 0).await?;
+ match self.focus {
+ Focus::Readline => {
+ self.history
+ .render(&mut self.output, self.readline.lines(), None)
+ .await?;
+ self.readline.render(&mut self.output).await?;
+ }
+ Focus::History(idx) => {
+ self.history.render(&mut self.output, 0, Some(idx)).await?;
+ }
}
self.output.refresh().await?;
Ok(())