diff --git a/src/config/mod.rs b/src/config/mod.rs index 30875dc9ec2..b07efdff9fd 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -460,6 +460,13 @@ pub struct Config { /// 10 seconds. #[serde(default)] pub periodic_stat_logging: u64, + + /// If false, do not scroll to the bottom of the terminal when + /// you send input to the terminal. + /// The default is to scroll to the bottom when you send input + /// to the terminal. + #[serde(default = "default_true")] + pub scroll_to_bottom_on_input: bool, } #[derive(Deserialize, Clone, Copy, Debug)] diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index ee9b4d53ab1..25279d96e5e 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -389,6 +389,7 @@ impl WindowCallbacks for TermWindow { && modifiers.contains(::termwiz::input::Modifiers::ALT) && tab.key_down(key, modifiers).is_ok() { + self.maybe_scroll_to_bottom_for_input(&tab); return true; } } @@ -401,6 +402,7 @@ impl WindowCallbacks for TermWindow { self.perform_key_assignment(&tab, &assignment).ok(); true } else if tab.key_down(key, modifiers).is_ok() { + self.maybe_scroll_to_bottom_for_input(&tab); true } else { false @@ -408,6 +410,7 @@ impl WindowCallbacks for TermWindow { } Key::Composed(s) => { tab.writer().write_all(s.as_bytes()).ok(); + self.maybe_scroll_to_bottom_for_input(&tab); true } Key::None => false, @@ -2668,6 +2671,16 @@ impl TermWindow { } } } + + fn maybe_scroll_to_bottom_for_input(&mut self, tab: &Rc) { + if configuration().scroll_to_bottom_on_input { + self.scroll_to_bottom(tab); + } + } + + fn scroll_to_bottom(&mut self, tab: &Rc) { + self.tab_state(tab.tab_id()).viewport = None; + } } fn rgbcolor_to_window_color(color: RgbColor) -> Color {