Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

linux: Fix `ctrl-0..9`, `ctrl-[`, `ctrl-^` (#35028)

Oleksiy Syvokon0af690080bc4
diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs
index d65118e994e..fe6a36baa85 100644
--- a/crates/gpui/src/platform/linux/platform.rs
+++ b/crates/gpui/src/platform/linux/platform.rs
@@ -845,9 +845,15 @@ impl crate::Keystroke {
{
if key.is_ascii_graphic() {
key_utf8.to_lowercase()
- // map ctrl-a to a
- } else if key_utf32 <= 0x1f {
- ((key_utf32 as u8 + 0x60) as char).to_string()
+ // map ctrl-a to `a`
+ // ctrl-0..9 may emit control codes like ctrl-[, but
+ // we don't want to map them to `[`
+ } else if key_utf32 <= 0x1f
+ && !name.chars().next().is_some_and(|c| c.is_ascii_digit())
+ {
+ ((key_utf32 as u8 + 0x40) as char)
+ .to_ascii_lowercase()
+ .to_string()
} else {
name
}