From 6db0b6c5ad8f9ba6183da6b0ee5839eb3d013029 Mon Sep 17 00:00:00 2001 From: Denis Washington Date: Thu, 11 Jul 2024 10:20:54 +0200 Subject: [PATCH] terminal: Prevent extra character on handled meta keystrokes (#14151) On macOS, when `terminal.option_as_meta` is enabled, pressing key combinations like `option+b` and `option+f` would lead to both an escape sequence being sent to the terminal (the expected behavior with `option_as_meta == true`) AND a character being inserted (the behavior when `option_as_meta == false`). Prevent the latter by stopping propagation of the key-down event if it corresponds to a terminal escape sequence and `option_as_meta` is enabled. Fixes #7728 Release Notes: - Fixed insertion of extra characters for some keystrokes if `terminal.option_as_meta` is enabled ([#7728](https://github.com/zed-industries/zed/issues/7728)). --- crates/terminal_view/src/terminal_view.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 7b9a5e44347ba6a8274c573c6860631443c8458c..788e057581358815781988291f24aa8226b35812 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -864,10 +864,13 @@ impl TerminalView { self.pause_cursor_blinking(cx); self.terminal.update(cx, |term, cx| { - term.try_keystroke( + let handled = term.try_keystroke( &event.keystroke, TerminalSettings::get_global(cx).option_as_meta, - ) + ); + if handled { + cx.stop_propagation(); + } }); }