mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
fix(tui): restore alt-enter newline alias (#20535)
Fixes https://github.com/openai/codex/issues/20501 ## Summary - add Alt+Enter to the built-in editor newline aliases - update keymap tests that used Alt+Enter as a custom submit binding now that it conflicts with newline - refresh the keymap action-menu snapshot fixture ## Test Plan - `just fmt` - `cargo test -p codex-tui keymap::tests` - `cargo test -p codex-tui bottom_pane::textarea::tests` - `cargo test -p codex-tui keymap_setup::tests` - `cargo test -p codex-tui` - `cargo insta pending-snapshots` - `git diff --check` - `just argument-comment-lint`
This commit is contained in:
@@ -557,7 +557,8 @@ impl RuntimeKeymap {
|
||||
ctrl(KeyCode::Char('j')),
|
||||
ctrl(KeyCode::Char('m')),
|
||||
plain(KeyCode::Enter),
|
||||
shift(KeyCode::Enter)
|
||||
shift(KeyCode::Enter),
|
||||
alt(KeyCode::Enter)
|
||||
],
|
||||
move_left: default_bindings![plain(KeyCode::Left), ctrl(KeyCode::Char('b'))],
|
||||
move_right: default_bindings![plain(KeyCode::Right), ctrl(KeyCode::Char('f'))],
|
||||
@@ -1516,7 +1517,7 @@ mod tests {
|
||||
|
||||
keymap.composer.submit = Some(KeybindingsSpec::Many(vec![
|
||||
KeybindingSpec("ctrl-enter".to_string()),
|
||||
KeybindingSpec("alt-enter".to_string()),
|
||||
KeybindingSpec("ctrl-shift-enter".to_string()),
|
||||
]));
|
||||
|
||||
let runtime = RuntimeKeymap::from_config(&keymap).expect("valid multi-binding");
|
||||
@@ -1529,7 +1530,7 @@ mod tests {
|
||||
keymap.composer.submit = Some(KeybindingsSpec::Many(vec![
|
||||
KeybindingSpec("ctrl-enter".to_string()),
|
||||
KeybindingSpec("ctrl-enter".to_string()),
|
||||
KeybindingSpec("alt-enter".to_string()),
|
||||
KeybindingSpec("ctrl-shift-enter".to_string()),
|
||||
]));
|
||||
|
||||
let runtime = RuntimeKeymap::from_config(&keymap).expect("valid multi-binding");
|
||||
@@ -1537,7 +1538,7 @@ mod tests {
|
||||
runtime.composer.submit,
|
||||
vec![
|
||||
key_hint::ctrl(KeyCode::Enter),
|
||||
key_hint::alt(KeyCode::Enter)
|
||||
KeyBinding::new(KeyCode::Enter, KeyModifiers::CONTROL | KeyModifiers::SHIFT)
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1798,13 +1799,17 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_editor_insert_newline_includes_shift_enter() {
|
||||
fn default_editor_insert_newline_includes_current_aliases() {
|
||||
let runtime = RuntimeKeymap::defaults();
|
||||
assert!(
|
||||
runtime
|
||||
.editor
|
||||
.insert_newline
|
||||
.contains(&key_hint::shift(KeyCode::Enter))
|
||||
assert_eq!(
|
||||
runtime.editor.insert_newline,
|
||||
vec![
|
||||
key_hint::ctrl(KeyCode::Char('j')),
|
||||
key_hint::ctrl(KeyCode::Char('m')),
|
||||
key_hint::plain(KeyCode::Enter),
|
||||
key_hint::shift(KeyCode::Enter),
|
||||
key_hint::alt(KeyCode::Enter),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1150,7 +1150,7 @@ mod tests {
|
||||
&TuiKeymap::default(),
|
||||
"composer",
|
||||
"submit",
|
||||
&["ctrl-enter".to_string(), "alt-enter".to_string()],
|
||||
&["ctrl-enter".to_string(), "alt-shift-enter".to_string()],
|
||||
)
|
||||
.expect("multi binding");
|
||||
let multi_runtime = RuntimeKeymap::from_config(&multi_keymap).expect("runtime keymap");
|
||||
@@ -1465,7 +1465,7 @@ mod tests {
|
||||
&TuiKeymap::default(),
|
||||
"composer",
|
||||
"submit",
|
||||
&["ctrl-enter".to_string(), "alt-enter".to_string()],
|
||||
&["ctrl-enter".to_string(), "alt-shift-enter".to_string()],
|
||||
)
|
||||
.expect("multi binding");
|
||||
let runtime = RuntimeKeymap::from_config(&keymap).expect("runtime keymap");
|
||||
@@ -1586,7 +1586,7 @@ mod tests {
|
||||
&TuiKeymap::default(),
|
||||
"composer",
|
||||
"submit",
|
||||
&["ctrl-enter".to_string(), "alt-enter".to_string()],
|
||||
&["ctrl-enter".to_string(), "alt-shift-enter".to_string()],
|
||||
)
|
||||
.expect("multi binding");
|
||||
let runtime = RuntimeKeymap::from_config(&keymap).expect("runtime keymap");
|
||||
@@ -1610,12 +1610,12 @@ mod tests {
|
||||
else {
|
||||
panic!("expected updated keymap");
|
||||
};
|
||||
assert_eq!(bindings, vec!["ctrl-shift-enter", "alt-enter"]);
|
||||
assert_eq!(bindings, vec!["ctrl-shift-enter", "alt-shift-enter"]);
|
||||
assert_eq!(
|
||||
keymap_config.composer.submit,
|
||||
Some(KeybindingsSpec::Many(vec![
|
||||
KeybindingSpec("ctrl-shift-enter".to_string()),
|
||||
KeybindingSpec("alt-enter".to_string())
|
||||
KeybindingSpec("alt-shift-enter".to_string())
|
||||
]))
|
||||
);
|
||||
}
|
||||
@@ -1626,7 +1626,7 @@ mod tests {
|
||||
&TuiKeymap::default(),
|
||||
"composer",
|
||||
"submit",
|
||||
&["ctrl-enter".to_string(), "alt-enter".to_string()],
|
||||
&["ctrl-enter".to_string(), "ctrl-shift-enter".to_string()],
|
||||
)
|
||||
.expect("multi binding");
|
||||
let runtime = RuntimeKeymap::from_config(&keymap).expect("runtime keymap");
|
||||
@@ -1635,7 +1635,7 @@ mod tests {
|
||||
&runtime,
|
||||
"composer",
|
||||
"submit",
|
||||
"alt-enter",
|
||||
"ctrl-shift-enter",
|
||||
&KeymapEditIntent::ReplaceOne {
|
||||
old_key: "ctrl-enter".to_string(),
|
||||
},
|
||||
@@ -1650,11 +1650,11 @@ mod tests {
|
||||
else {
|
||||
panic!("expected updated keymap");
|
||||
};
|
||||
assert_eq!(bindings, vec!["alt-enter"]);
|
||||
assert_eq!(bindings, vec!["ctrl-shift-enter"]);
|
||||
assert_eq!(
|
||||
keymap_config.composer.submit,
|
||||
Some(KeybindingsSpec::One(KeybindingSpec(
|
||||
"alt-enter".to_string()
|
||||
"ctrl-shift-enter".to_string()
|
||||
)))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,4 +22,4 @@ Back to shortcuts | Return to the shortcut list. | enabled
|
||||
|
||||
replace picker:
|
||||
ctrl-enter | Replace this binding. | enabled
|
||||
alt-enter | Replace this binding. | enabled
|
||||
alt-shift-enter | Replace this binding. | enabled
|
||||
|
||||
Reference in New Issue
Block a user