mirror of
https://github.com/openai/codex.git
synced 2026-11-20 07:06:24 +00:00
Share editor keymaps across TUI composer components (#38837)
## What changed - Store the editor portion of `RuntimeKeymap` in an `Arc` so the chat composer and its embedded textarea use the same keymap snapshot. - Initialize the textarea from the composer's default runtime keymap and keep custom binding updates shared between both components. - Use copy-on-write when tests and binding resolution need to mutate editor bindings. ## Testing - Verify that applying custom editor bindings shares the same keymap allocation with the composer and textarea. GitOrigin-RevId: 7f3b0afd6cc784e23deee8819e5c2c37a3709c68
This commit is contained in:
1 parent
73abda8bfe
commit
9bfaf7a076
5 files changed
+36
-19
No files matched your search
@@ -5,6 +5,7 @@ use crossterm::event::KeyModifiers;
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc::unbounded_channel;
|
||||
|
||||
use super::StartupDraftInitialScreen;
|
||||
@@ -483,10 +484,11 @@ fn startup_draft_allows_local_editor_shortcuts_without_startup_actions() {
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "first ");
|
||||
|
||||
let mut keymap = crate::keymap::RuntimeKeymap::defaults();
|
||||
keymap.editor.move_line_start = vec![crate::key_hint::ctrl(KeyCode::Char('z'))];
|
||||
keymap.editor.move_line_end = vec![crate::key_hint::ctrl(KeyCode::Char('v'))];
|
||||
keymap.editor.move_left = vec![crate::key_hint::ctrl(KeyCode::Char('s'))];
|
||||
keymap.editor.insert_newline = vec![crate::key_hint::plain(KeyCode::Enter)];
|
||||
let editor = Arc::make_mut(&mut keymap.editor);
|
||||
editor.move_line_start = vec![crate::key_hint::ctrl(KeyCode::Char('z'))];
|
||||
editor.move_line_end = vec![crate::key_hint::ctrl(KeyCode::Char('v'))];
|
||||
editor.move_left = vec![crate::key_hint::ctrl(KeyCode::Char('s'))];
|
||||
editor.insert_newline = vec![crate::key_hint::plain(KeyCode::Enter)];
|
||||
keymap.composer.submit = vec![crate::key_hint::ctrl(KeyCode::Char('s'))];
|
||||
pump.bottom_pane.set_keymap_bindings(&keymap);
|
||||
handle_startup_draft_key(
|
||||
|
||||
Reference in new issue
Block a user