This commit is contained in:
Dylan Hurd
2026-02-15 11:09:08 -08:00
parent 293c8af02d
commit 98eb6dc814
2 changed files with 34 additions and 2 deletions

View File

@@ -784,9 +784,13 @@ impl ChatComposer {
enabled
}
pub(crate) fn is_vim_insert(&self) -> bool {
self.textarea.is_vim_insert()
}
fn vim_mode_indicator_span(&self) -> Option<Span<'static>> {
self.textarea.vim_mode_label().map(|label| match label {
"Normal" => "Vim: Normal".yellow(),
"Normal" => "Vim: Normal".magenta(),
"Insert" => "Vim: Insert".green(),
_ => unreachable!(),
})

View File

@@ -751,7 +751,10 @@ impl BottomPane {
/// overlays or popups and not running a task. This is the safe context to
/// use Esc-Esc for backtracking from the main view.
pub(crate) fn is_normal_backtrack_mode(&self) -> bool {
!self.is_task_running && self.view_stack.is_empty() && !self.composer.popup_active()
!self.is_task_running
&& self.view_stack.is_empty()
&& !self.composer.popup_active()
&& !self.composer.is_vim_insert()
}
/// Return true when no popups or modal views are active, regardless of task state.
@@ -1498,6 +1501,31 @@ mod tests {
);
}
#[test]
fn normal_backtrack_mode_excludes_vim_insert() {
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
let tx = AppEventSender::new(tx_raw);
let mut pane = BottomPane::new(BottomPaneParams {
app_event_tx: tx,
frame_requester: FrameRequester::test_dummy(),
has_input_focus: true,
enhanced_keys_supported: false,
placeholder_text: "Ask Codex to do anything".to_string(),
disable_paste_burst: false,
animations_enabled: true,
skills: Some(Vec::new()),
});
pane.toggle_vim_enabled();
assert!(pane.is_normal_backtrack_mode());
pane.handle_key_event(KeyEvent::new(KeyCode::Char('i'), KeyModifiers::NONE));
assert!(!pane.is_normal_backtrack_mode());
pane.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
assert!(pane.is_normal_backtrack_mode());
}
#[test]
fn esc_routes_to_handle_key_event_when_requested() {
#[derive(Default)]