Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
terminal: Fix vi mode cursor not updating on k/j navigation (#46762)
xcb3db4d1ba7a0d51
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex 21c5a23c7fe..3c482286f89 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -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>) {