Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix Shift+Enter to send newline instead of carriage return in terminal (#33859)
Taras Martyniuk0ebf7f54bb4f
diff --git a/crates/terminal/src/mappings/keys.rs b/crates/terminal/src/mappings/keys.rsindex a9139ae6013..b003bf82ad3 100644--- a/crates/terminal/src/mappings/keys.rs+++ b/crates/terminal/src/mappings/keys.rs@@ -56,7 +56,7 @@ pub fn to_esc_str(("tab", AlacModifiers::None) => Some("\x09"),("escape", AlacModifiers::None) => Some("\x1b"),("enter", AlacModifiers::None) => Some("\x0d"),- ("enter", AlacModifiers::Shift) => Some("\x0d"),+ ("enter", AlacModifiers::Shift) => Some("\x0a"),("enter", AlacModifiers::Alt) => Some("\x1b\x0d"),("backspace", AlacModifiers::None) => Some("\x7f"),//Interesting escape codes@@ -406,6 +406,22 @@ mod test {}}+ #[test]+ fn test_shift_enter_newline() {+ let shift_enter = Keystroke::parse("shift-enter").unwrap();+ let regular_enter = Keystroke::parse("enter").unwrap();+ let mode = TermMode::NONE;++ // Shift-enter should send line feed (newline)+ assert_eq!(to_esc_str(&shift_enter, &mode, false), Some("\x0a".into()));++ // Regular enter should still send carriage return+ assert_eq!(+ to_esc_str(®ular_enter, &mode, false),+ Some("\x0d".into())+ );+ }+#[test]fn test_modifier_code_calc() {// Code Modifiers