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)).
This commit is contained in:
Denis Washington 2024-07-11 10:20:54 +02:00 committed by GitHub
parent ba11e9a9a8
commit 6db0b6c5ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();
}
});
}