mirror of
https://github.com/openai/codex.git
synced 2026-11-14 06:48:26 +00:00
Keep agent-switch word-motion keys out of draft editing (#14376)
## Summary - only trigger multi-agent fast-switch shortcuts when the composer is empty - keep the Option+b/f fallback for terminals that encode Option+arrow that way - document why the empty-composer gate preserves expected word-wise editing behavior ## Testing - just fmt - cargo test -p codex-tui Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
1 parent
5a89660ae4
commit
f548309797
2 files changed
+49
-5
No files matched your search
@@ -3686,10 +3686,18 @@ impl App {
|
||||
}
|
||||
|
||||
async fn handle_key_event(&mut self, tui: &mut tui::Tui, key_event: KeyEvent) {
|
||||
// Some terminals, especially on macOS, encode Option+Left/Right as Option+b/f unless
|
||||
// enhanced keyboard reporting is available. We only treat those word-motion fallbacks as
|
||||
// agent-switch shortcuts when the composer is empty so we never steal the expected
|
||||
// editing behavior for moving across words inside a draft.
|
||||
let allow_agent_word_motion_fallback = !self.enhanced_keys_supported
|
||||
&& self.chat_widget.composer_text_with_pending().is_empty();
|
||||
if self.overlay.is_none()
|
||||
&& self.chat_widget.no_modal_or_popup_active()
|
||||
// Alt+Left/Right are also natural word-motion keys in the composer. Keep agent
|
||||
// fast-switch available only once the draft is empty so editing behavior wins whenever
|
||||
// there is text on screen.
|
||||
&& self.chat_widget.composer_text_with_pending().is_empty()
|
||||
&& previous_agent_shortcut_matches(key_event, allow_agent_word_motion_fallback)
|
||||
{
|
||||
if let Some(thread_id) = self.agent_navigation.adjacent_thread_id(
|
||||
@@ -3702,6 +3710,9 @@ impl App {
|
||||
}
|
||||
if self.overlay.is_none()
|
||||
&& self.chat_widget.no_modal_or_popup_active()
|
||||
// Mirror the previous-agent rule above: empty drafts may use these keys for thread
|
||||
// switching, but non-empty drafts keep them for expected word-wise cursor motion.
|
||||
&& self.chat_widget.composer_text_with_pending().is_empty()
|
||||
&& next_agent_shortcut_matches(key_event, allow_agent_word_motion_fallback)
|
||||
{
|
||||
if let Some(thread_id) = self.agent_navigation.adjacent_thread_id(
|
||||
|
||||
Reference in new issue
Block a user