diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-11 04:52:40 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-11 04:55:02 -0500 |
commit | 7fdbec0826efc577dc743d0240f6665669a1ed5f (patch) | |
tree | 11db9e5cbf968ec034b9b9667e248d3fbc4d66b6 /src/state.rs | |
parent | 78db259912ae5d2b71ee98248ae1acae2f9c3d5b (diff) | |
download | nbsh-7fdbec0826efc577dc743d0240f6665669a1ed5f.tar.gz nbsh-7fdbec0826efc577dc743d0240f6665669a1ed5f.zip |
try harder to keep the focused line visible
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/state.rs b/src/state.rs index 9d10b74..0b54815 100644 --- a/src/state.rs +++ b/src/state.rs @@ -227,7 +227,22 @@ impl State { ) { let mut hard_refresh = false; match action { - crate::action::Action::Render => {} + crate::action::Action::Render => { + // for instance, if we are rerendering because of command + // output, that output could increase the number of lines of + // output of a command, pushing the currently focused entry + // off the top of the screen + self.history + .make_focus_visible( + self.readline.lines(), + self.focus_idx(), + matches!( + self.focus, + crate::action::Focus::Scrolling(_) + ), + ) + .await; + } crate::action::Action::ForceRedraw => { hard_refresh = true; } |