Apply composer editing preferences to TUI text prompts (#39618)

## What changed

- Initialize custom text prompts with the main composer's editor keybindings and Vim setting.
- Support Vim mode transitions, operator sequences, cursor styles, keymap contexts, and mode-aware footer hints in these prompts.
- Start Vim prompts in insert mode, use the first `Esc` to enter normal mode, and preserve `Esc` cancellation outside Vim.

## Testing

- Cover remapped editor and Vim commands, mode and context transitions, paste handling, cancellation, and footer rendering at different widths.

GitOrigin-RevId: 7a678310639dafb938084197df23d6d2a080a051
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-08-20 06:35:47 +00:00
1 parent bc3545b805
commit 4bb7804a23
10 files changed
+245 -28

No files matched your search

+14
View File
@@ -33,6 +33,8 @@ use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::Color;
use ratatui::style::Style;
use ratatui::style::Stylize;
use ratatui::text::Span;
use ratatui::widgets::StatefulWidgetRef;
use ratatui::widgets::WidgetRef;
use std::borrow::Cow;
@@ -356,6 +358,7 @@ impl TextArea {
/// `None` means Vim editing is disabled, so callers should omit the mode
/// indicator rather than rendering an insert-mode label for normal
/// non-modal editing.
#[cfg(test)]
pub(crate) fn vim_mode_label(&self) -> Option<&'static str> {
if !self.vim_enabled {
return None;
@@ -366,6 +369,17 @@ impl TextArea {
})
}
/// Return the styled footer indicator for the active Vim editing mode.
pub(crate) fn vim_mode_indicator_span(&self) -> Option<Span<'static>> {
if !self.vim_enabled {
return None;
}
Some(match self.vim_mode {
VimMode::Normal => "Vim: Normal".magenta(),
VimMode::Insert => "Vim: Insert".green(),
})
}
pub fn text(&self) -> &str {
&self.text
}