mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
tui: refine slash help search controls
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
Codex
parent
77e1e8029a
commit
6e20c5af8c
@@ -212,7 +212,7 @@ impl SlashHelpView {
|
||||
]);
|
||||
}
|
||||
|
||||
Line::from(vec![
|
||||
let mut spans = vec![
|
||||
key_hint::plain(KeyCode::Up).into(),
|
||||
"/".into(),
|
||||
key_hint::plain(KeyCode::Down).into(),
|
||||
@@ -222,11 +222,16 @@ impl SlashHelpView {
|
||||
key_hint::plain(KeyCode::PageDown).into(),
|
||||
" page ".dim(),
|
||||
"/ search ".dim(),
|
||||
"n/p match ".dim(),
|
||||
];
|
||||
if !self.search.active_query.is_empty() {
|
||||
spans.push("n/p match ".dim());
|
||||
}
|
||||
spans.extend([
|
||||
"q/".dim(),
|
||||
key_hint::plain(KeyCode::Esc).into(),
|
||||
" close".dim(),
|
||||
])
|
||||
]);
|
||||
Line::from(spans)
|
||||
}
|
||||
|
||||
fn wrap_rows(rows: &[HelpRow], width: u16) -> (Vec<Line<'static>>, Vec<usize>, Vec<usize>) {
|
||||
@@ -321,7 +326,10 @@ impl BottomPaneView for SlashHelpView {
|
||||
modifiers: KeyModifiers::NONE,
|
||||
..
|
||||
} => {
|
||||
self.search.input = Some(self.search.active_query.clone());
|
||||
self.search.active_query.clear();
|
||||
self.search.selected_match = 0;
|
||||
self.follow_selected_match.set(false);
|
||||
self.search.input = Some(String::new());
|
||||
}
|
||||
KeyEvent {
|
||||
code: KeyCode::Up, ..
|
||||
|
||||
+1
-1
@@ -240,4 +240,4 @@ expression: popup
|
||||
/debug-m-drop
|
||||
|
||||
/debug-m-update
|
||||
↑/↓ scroll pgup/pgdn page / search n/p match q/esc close 1-233/239
|
||||
↑/↓ scroll pgup/pgdn page / search q/esc close 1-233/239
|
||||
|
||||
@@ -6076,6 +6076,28 @@ async fn slash_help_search_navigates_matches_with_n_and_p() {
|
||||
assert!(previous.contains("2/3 |"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn slash_help_search_restarts_from_empty_input() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
||||
|
||||
chat.dispatch_command(SlashCommand::Help);
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Char('/')));
|
||||
for ch in "maintainers".chars() {
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Char(ch)));
|
||||
}
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
|
||||
|
||||
let active = render_bottom_popup(&chat, 100);
|
||||
assert!(active.contains("1/1 |"));
|
||||
assert!(active.contains("n/p match"));
|
||||
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Char('/')));
|
||||
let restarted = render_bottom_popup(&chat, 100);
|
||||
assert!(restarted.contains("Search: /"));
|
||||
assert!(!restarted.contains("Search: /maintainers"));
|
||||
assert!(!restarted.contains("1/1 |"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn slash_help_esc_dismisses_popup() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
||||
|
||||
Reference in New Issue
Block a user