mirror of
https://github.com/openai/codex.git
synced 2026-11-05 20:10:33 +00:00
Preserve modified Ctrl+C keys in active TUI views (#58990)
## Why The keypress inspector could not display `ctrl-alt-c` or `ctrl-shift-c` because these keys bypassed the active view as if they were plain `Ctrl+C`. ## What changed Require the modifier set to be exactly Control for the `Ctrl+C` exception when routing keys to active views. Keys with additional modifiers now reach the active view. ## Testing Add regression coverage verifying that the inspector displays `ctrl-alt-c` and `ctrl-shift-c`, while plain `Ctrl+C` still closes it for either uppercase or lowercase `C`. GitOrigin-RevId: cdad4dc73c096e6f07d1a951123db981c4837eac
This commit is contained in:
@@ -54,3 +54,30 @@ async fn selection_copy_cancels_a_pending_find_editor_chord() -> Result<()> {
|
||||
tui.set_owned_screen(/*owned*/ false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn keypress_inspector_distinguishes_ctrl_alt_c_from_ctrl_c() -> Result<()> {
|
||||
let mut app = crate::app::test_support::make_test_app().await;
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
for (modifier, expected, cancel) in [
|
||||
(KeyModifiers::ALT, "ctrl-alt-c", 'c'),
|
||||
(KeyModifiers::SHIFT, "ctrl-shift-c", 'C'),
|
||||
] {
|
||||
app.chat_widget.open_keymap_debug(&app.keymap);
|
||||
let inspect = KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL | modifier);
|
||||
let inspect = app
|
||||
.route_key_chord_event(&mut tui, inspect)
|
||||
.expect("physical inspector key");
|
||||
app.chat_widget.handle_key_event(inspect);
|
||||
let screen =
|
||||
crate::chatwidget::tests::render_bottom_popup(&app.chat_widget, /*width*/ 80);
|
||||
assert!(
|
||||
screen.contains(&format!("Config key: {expected}")),
|
||||
"{screen}"
|
||||
);
|
||||
app.chat_widget
|
||||
.handle_key_event(KeyEvent::new(KeyCode::Char(cancel), KeyModifiers::CONTROL));
|
||||
assert!(!app.chat_widget.has_active_view());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ impl ChatWidget {
|
||||
modifiers,
|
||||
kind: KeyEventKind::Press,
|
||||
..
|
||||
} if modifiers.contains(KeyModifiers::CONTROL) && c.eq_ignore_ascii_case(&'c')
|
||||
} if modifiers == KeyModifiers::CONTROL && c.eq_ignore_ascii_case(&'c')
|
||||
)
|
||||
&& (self.bottom_pane.warnings_active()
|
||||
|| (!key_hint::ctrl(KeyCode::Char('r')).is_press(key_event)
|
||||
|
||||
Reference in New Issue
Block a user