mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add TUI building blocks for inline async question editing (#42889)
## What changed - Introduce an async-question editor component with per-question drafts, navigation, replay deduplication, and submit or queue handling using the shared composer. - Add bounded `AnsweredQuestion` framing that truncates question text at a UTF-8 boundary and flattens line breaks before prepending it to an answer. - Add `prompt_stack_back` and `skip_question` keybinding actions and the `tui.question_esc_back` setting. Normalize `Ctrl+]` and `Ctrl+5` for key matching and conflict detection, and let default question shortcuts yield to explicit bindings. - Flush buffered typing in both the main composer and the covering view so background input cannot keep the draw loop waiting. The async-question component is not yet connected to the TUI event flow. ## Testing Add regression coverage for bounded Unicode question framing, question-shortcut conflicts, and paste-buffer flushing in background and covering editors. GitOrigin-RevId: 4098043cf588ddafc05c27505645495edd690cb9
This commit is contained in:
1 parent
574a36ff99
commit
6ae8dcf6e1
32 files changed
+750
-44
No files matched your search
@@ -96,6 +96,14 @@ impl KeyBinding {
|
||||
(self.key, self.modifiers)
|
||||
}
|
||||
|
||||
/// Legacy Ctrl+] is reported as Ctrl+5; keep matching and conflicts consistent.
|
||||
pub(crate) fn normalized_parts(&self) -> (KeyCode, KeyModifiers) {
|
||||
match self.parts() {
|
||||
(KeyCode::Char('5'), KeyModifiers::CONTROL) => ctrl(KeyCode::Char(']')).parts(),
|
||||
parts => parts,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn display_label(&self) -> String {
|
||||
let modifiers = modifiers_to_string(self.modifiers);
|
||||
let key = match self.key {
|
||||
@@ -123,13 +131,13 @@ pub(crate) fn normalize_key_parts(
|
||||
if modifiers.is_empty()
|
||||
&& let Some(ctrl_char) = c0_control_char_to_ctrl_char(ch)
|
||||
{
|
||||
return (KeyCode::Char(ctrl_char), KeyModifiers::CONTROL | modifiers);
|
||||
return normalize_key_parts(KeyCode::Char(ctrl_char), KeyModifiers::CONTROL);
|
||||
}
|
||||
if ch.is_ascii_uppercase() {
|
||||
modifiers.insert(KeyModifiers::SHIFT);
|
||||
return (KeyCode::Char(ch.to_ascii_lowercase()), modifiers);
|
||||
}
|
||||
(key, modifiers)
|
||||
KeyBinding::new(key, modifiers).normalized_parts()
|
||||
}
|
||||
|
||||
fn c0_control_char_to_ctrl_char(ch: char) -> Option<char> {
|
||||
@@ -350,6 +358,7 @@ mod tests {
|
||||
('z', '\u{001a}'),
|
||||
('4', '\u{001c}'),
|
||||
('5', '\u{001d}'),
|
||||
(']', '\u{001d}'),
|
||||
('6', '\u{001e}'),
|
||||
('7', '\u{001f}'),
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user