From b45d5e83bbd4e8733cc9596f59542465adf16557 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 13 Sep 2022 09:39:29 -0700 Subject: [PATCH] Added tests for alt->meta behavior --- crates/terminal/src/mappings/keys.rs | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/terminal/src/mappings/keys.rs b/crates/terminal/src/mappings/keys.rs index 1a3d7c6454..199f42df65 100644 --- a/crates/terminal/src/mappings/keys.rs +++ b/crates/terminal/src/mappings/keys.rs @@ -405,6 +405,40 @@ mod test { } } + #[test] + fn alt_is_meta() { + let ascii_printable = ' '..='~'; + for character in ascii_printable { + assert_eq!( + to_esc_str( + &Keystroke::parse(&format!("alt-{}", character)).unwrap(), + &TermMode::NONE, + true + ) + .unwrap(), + format!("\x1b{}", character) + ); + } + + let gpui_keys = [ + "up", "down", "right", "left", "f1", "f2", "f3", "f4", "F5", "f6", "f7", "f8", "f9", + "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "insert", + "pageup", "pagedown", "end", "home", + ]; + + for key in gpui_keys { + assert_ne!( + to_esc_str( + &Keystroke::parse(&format!("alt-{}", key)).unwrap(), + &TermMode::NONE, + true + ) + .unwrap(), + format!("\x1b{}", key) + ); + } + } + #[test] fn test_modifier_code_calc() { // Code Modifiers