Fix Shift+Enter to send newline instead of carriage return in terminal (#33859)
Closes #33858 Changes Shift+Enter in the built-in terminal to send line feed (`\x0a`) instead of carriage return (`\x0d`), enabling multi-line input in Claude Code and other terminal applications. Release Notes: - Fixed the issue where Claude Code and other multi-line terminal applications couldn't use Shift+Enter for newlines.
This commit is contained in:
parent
7a2593e520
commit
0ebf7f54bb
1 changed files with 17 additions and 1 deletions
|
@ -56,7 +56,7 @@ pub fn to_esc_str(
|
||||||
("tab", AlacModifiers::None) => Some("\x09"),
|
("tab", AlacModifiers::None) => Some("\x09"),
|
||||||
("escape", AlacModifiers::None) => Some("\x1b"),
|
("escape", AlacModifiers::None) => Some("\x1b"),
|
||||||
("enter", AlacModifiers::None) => Some("\x0d"),
|
("enter", AlacModifiers::None) => Some("\x0d"),
|
||||||
("enter", AlacModifiers::Shift) => Some("\x0d"),
|
("enter", AlacModifiers::Shift) => Some("\x0a"),
|
||||||
("enter", AlacModifiers::Alt) => Some("\x1b\x0d"),
|
("enter", AlacModifiers::Alt) => Some("\x1b\x0d"),
|
||||||
("backspace", AlacModifiers::None) => Some("\x7f"),
|
("backspace", AlacModifiers::None) => Some("\x7f"),
|
||||||
//Interesting escape codes
|
//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]
|
#[test]
|
||||||
fn test_modifier_code_calc() {
|
fn test_modifier_code_calc() {
|
||||||
// Code Modifiers
|
// Code Modifiers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue