diff --git a/codex-rs/config/src/tui_keymap.rs b/codex-rs/config/src/tui_keymap.rs index 3e8be83d6..90d82da93 100644 --- a/codex-rs/config/src/tui_keymap.rs +++ b/codex-rs/config/src/tui_keymap.rs @@ -494,6 +494,7 @@ fn normalize_key_name(key: &str, original: &str) -> Result { | "page-up" | "page-down" | "space" + | "minus" ) { return Ok(alias.to_string()); } @@ -508,7 +509,7 @@ fn normalize_key_name(key: &str, original: &str) -> Result { Err(format!( "unknown key `{key}` in keybinding `{original}`. \ Use a printable character (for example `a`), function keys (`f1`-`f12`), \ -or one of: enter, tab, backspace, esc, delete, arrows, home/end, page-up/page-down, space.\n\ +or one of: enter, tab, backspace, esc, delete, arrows, home/end, page-up/page-down, space, minus.\n\ See the Codex keymap documentation for supported actions and examples." )) } @@ -516,6 +517,7 @@ See the Codex keymap documentation for supported actions and examples." #[cfg(test)] mod tests { use super::*; + use pretty_assertions::assert_eq; #[test] fn misplaced_action_at_keymap_root_is_rejected() { @@ -581,4 +583,30 @@ mod tests { let keymap: TuiKeymap = toml::from_str(toml_input).expect("valid config"); assert!(keymap.global.open_transcript.is_some()); } + + #[test] + fn minus_bindings_under_global_context_are_accepted() { + for (spec, expected) in [ + ( + "minus", + KeybindingsSpec::One(KeybindingSpec("minus".to_string())), + ), + ( + "alt-minus", + KeybindingsSpec::One(KeybindingSpec("alt-minus".to_string())), + ), + ] { + let toml_input = format!( + r#" + [global] + open_transcript = "{spec}" + "# + ); + let keymap: TuiKeymap = toml::from_str(&toml_input).expect("valid config"); + let mut expected_keymap = TuiKeymap::default(); + expected_keymap.global.open_transcript = Some(expected); + + assert_eq!(keymap, expected_keymap); + } + } }