mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Start fresh Vim drafts in Insert mode (#41921)
## What changed - Start the composer in Vim Insert mode when Vim is enabled and return to Insert mode after submissions and slash-command dispatch. - Record the fresh Insert session as a Vim edit so `.` can repeat text entered in a new draft. - Keep `/` and `?` as Normal-mode composer searches, and let Backspace cancel an empty search query and any pending operator without changing the draft. ## Testing - Add coverage for startup, submitted and queued drafts, inline and goal slash commands, repeatable edits, and canceled searches. GitOrigin-RevId: 1a5ee30c44685d2b2a037e46c3ab4ab611024919
This commit is contained in:
1 parent
865bbf9a69
commit
0344625ccf
12 files changed
+137
-39
No files matched your search
@@ -1596,7 +1596,7 @@ async fn vim_mode_default_disabled_starts_composer_in_insert_mode() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn vim_mode_default_enabled_starts_composer_in_normal_mode() {
|
||||
async fn vim_mode_default_enabled_starts_composer_in_insert_mode() {
|
||||
let chat = make_startup_chat_with_cli_overrides(vec![(
|
||||
"tui.vim_mode_default".to_string(),
|
||||
TomlValue::Boolean(true),
|
||||
@@ -1606,8 +1606,13 @@ async fn vim_mode_default_enabled_starts_composer_in_normal_mode() {
|
||||
assert!(chat.bottom_pane.composer_is_vim_enabled());
|
||||
assert!(chat.composer_is_empty());
|
||||
let mut chat = chat;
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Char('x'), KeyModifiers::NONE));
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "");
|
||||
let empty_startup_draft = chat.bottom_pane.composer_draft_snapshot();
|
||||
chat.restore_startup_draft(empty_startup_draft);
|
||||
chat.handle_key_event(KeyCode::Char('x').into());
|
||||
chat.handle_key_event(KeyCode::Right.into());
|
||||
chat.handle_key_event(KeyCode::Esc.into());
|
||||
chat.handle_key_event(KeyCode::Char('.').into());
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "xx");
|
||||
}
|
||||
|
||||
async fn make_startup_chat_with_cli_overrides(
|
||||
|
||||
@@ -823,8 +823,12 @@ async fn goal_control_slash_commands_emit_goal_events() {
|
||||
chat.set_feature_enabled(Feature::Goals, /*enabled*/ true);
|
||||
let thread_id = ThreadId::new();
|
||||
chat.thread_id = Some(thread_id);
|
||||
chat.bottom_pane.set_vim_enabled(/*enabled*/ true);
|
||||
|
||||
submit_composer_text(&mut chat, command);
|
||||
chat.bottom_pane
|
||||
.set_composer_text(command.into(), Vec::new(), Vec::new());
|
||||
chat.handle_key_event(KeyCode::Esc.into());
|
||||
chat.handle_key_event(KeyCode::Enter.into());
|
||||
|
||||
match status {
|
||||
Some(status) => {
|
||||
@@ -850,6 +854,11 @@ async fn goal_control_slash_commands_emit_goal_events() {
|
||||
assert_eq!(actual_thread_id, thread_id);
|
||||
}
|
||||
}
|
||||
chat.handle_key_event(KeyCode::Char('x').into());
|
||||
chat.handle_key_event(KeyCode::Right.into());
|
||||
chat.handle_key_event(KeyCode::Esc.into());
|
||||
chat.handle_key_event(KeyCode::Char('.').into());
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "xx");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user