Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: Enable CTRL-n and CTRL-p for navigating slash commands, files, history (#1994)

Ejaz Ahmede30f65118d8a
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index 61539b6ed3..446563a192 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -410,6 +410,11 @@ impl ChatComposer {
match key_event {
KeyEvent {
code: KeyCode::Up, ..
+ }
+ | KeyEvent {
+ code: KeyCode::Char('p'),
+ modifiers: KeyModifiers::CONTROL,
+ ..
} => {
popup.move_up();
(InputResult::None, true)
@@ -417,6 +422,11 @@ impl ChatComposer {
KeyEvent {
code: KeyCode::Down,
..
+ }
+ | KeyEvent {
+ code: KeyCode::Char('n'),
+ modifiers: KeyModifiers::CONTROL,
+ ..
} => {
popup.move_down();
(InputResult::None, true)
@@ -584,6 +594,11 @@ impl ChatComposer {
match key_event {
KeyEvent {
code: KeyCode::Up, ..
+ }
+ | KeyEvent {
+ code: KeyCode::Char('p'),
+ modifiers: KeyModifiers::CONTROL,
+ ..
} => {
popup.move_up();
(InputResult::None, true)
@@ -591,6 +606,11 @@ impl ChatComposer {
KeyEvent {
code: KeyCode::Down,
..
+ }
+ | KeyEvent {
+ code: KeyCode::Char('n'),
+ modifiers: KeyModifiers::CONTROL,
+ ..
} => {
popup.move_down();
(InputResult::None, true)
@@ -870,6 +890,11 @@ impl ChatComposer {
KeyEvent {
code: KeyCode::Up | KeyCode::Down,
..
+ }
+ | KeyEvent {
+ code: KeyCode::Char('p') | KeyCode::Char('n'),
+ modifiers: KeyModifiers::CONTROL,
+ ..
} => {
if self
.history
@@ -878,6 +903,8 @@ impl ChatComposer {
let replace_text = match key_event.code {
KeyCode::Up => self.history.navigate_up(&self.app_event_tx),
KeyCode::Down => self.history.navigate_down(&self.app_event_tx),
+ KeyCode::Char('p') => self.history.navigate_up(&self.app_event_tx),
+ KeyCode::Char('n') => self.history.navigate_down(&self.app_event_tx),
_ => unreachable!(),
};
if let Some(text) = replace_text {