Lightweight coding agent that runs in your terminal
Rust
Fix #2429 Tweak the cursor position after tab completion (#2442)
Kazuhiro Sera16f11a89d8c0
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rsindex 71483f0495..5d555aa083 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs@@ -273,6 +273,7 @@ impl ChatComposer {if !starts_with_cmd {self.textarea.set_text(&format!("/{} ", cmd.command()));+ self.textarea.set_cursor(self.textarea.text().len());}}(InputResult::None, true)@@ -1071,6 +1072,28 @@ mod tests {}}+ #[test]+ fn slash_tab_completion_moves_cursor_to_end() {+ use crossterm::event::KeyCode;+ use crossterm::event::KeyEvent;+ use crossterm::event::KeyModifiers;++ let (tx, _rx) = std::sync::mpsc::channel();+ let sender = AppEventSender::new(tx);+ let mut composer =+ ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());++ for ch in ['/', 'c'] {+ let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));+ }++ let (_result, _needs_redraw) =+ composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));++ assert_eq!(composer.textarea.text(), "/compact ");+ assert_eq!(composer.textarea.cursor(), composer.textarea.text().len());+ }+#[test]fn slash_mention_dispatches_command_and_inserts_at() {use crossterm::event::KeyCode;