@@ -722,14 +722,7 @@ impl TerminalView {
fn send_keystroke(&mut self, text: &SendKeystroke, _: &mut Window, cx: &mut Context<Self>) {
if let Some(keystroke) = Keystroke::parse(&text.0).log_err() {
self.clear_bell(cx);
- self.terminal.update(cx, |term, cx| {
- let processed =
- term.try_keystroke(&keystroke, TerminalSettings::get_global(cx).option_as_meta);
- if processed && term.vi_mode_enabled() {
- cx.notify();
- }
- processed
- });
+ self.process_keystroke(&keystroke, cx);
}
}
@@ -1009,19 +1002,33 @@ impl ScrollbarVisibility for TerminalScrollbarSettingsWrapper {
}
impl TerminalView {
+ /// Attempts to process a keystroke in the terminal. Returns true if handled.
+ ///
+ /// In vi mode, explicitly triggers a re-render because vi navigation (like j/k)
+ /// updates the cursor locally without sending data to the shell, so there's no
+ /// shell output to automatically trigger a re-render.
+ fn process_keystroke(&mut self, keystroke: &Keystroke, cx: &mut Context<Self>) -> bool {
+ let (handled, vi_mode_enabled) = self.terminal.update(cx, |term, cx| {
+ (
+ term.try_keystroke(keystroke, TerminalSettings::get_global(cx).option_as_meta),
+ term.vi_mode_enabled(),
+ )
+ });
+
+ if handled && vi_mode_enabled {
+ cx.notify();
+ }
+
+ handled
+ }
+
fn key_down(&mut self, event: &KeyDownEvent, window: &mut Window, cx: &mut Context<Self>) {
self.clear_bell(cx);
self.pause_cursor_blinking(window, cx);
- self.terminal.update(cx, |term, cx| {
- let handled = term.try_keystroke(
- &event.keystroke,
- TerminalSettings::get_global(cx).option_as_meta,
- );
- if handled {
- cx.stop_propagation();
- }
- });
+ if self.process_keystroke(&event.keystroke, cx) {
+ cx.stop_propagation();
+ }
}
fn focus_in(&mut self, window: &mut Window, cx: &mut Context<Self>) {