Fix IME submissions dropping leading digits (#4359)
- ensure paste burst flush preserves ASCII characters before IME commits - add regression test covering digit followed by Japanese text submission Fixes openai/codex#4356 Co-authored-by: Josh McKinney <joshka@openai.com>
This commit is contained in:
@@ -2069,6 +2069,35 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ascii_prefix_survives_non_ascii_followup() {
|
||||||
|
use crossterm::event::KeyCode;
|
||||||
|
use crossterm::event::KeyEvent;
|
||||||
|
use crossterm::event::KeyModifiers;
|
||||||
|
|
||||||
|
let (tx, _rx) = unbounded_channel::<AppEvent>();
|
||||||
|
let sender = AppEventSender::new(tx);
|
||||||
|
let mut composer = ChatComposer::new(
|
||||||
|
true,
|
||||||
|
sender,
|
||||||
|
false,
|
||||||
|
"Ask Codex to do anything".to_string(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('1'), KeyModifiers::NONE));
|
||||||
|
assert!(composer.is_in_paste_burst());
|
||||||
|
|
||||||
|
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('あ'), KeyModifiers::NONE));
|
||||||
|
|
||||||
|
let (result, _) =
|
||||||
|
composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
|
||||||
|
match result {
|
||||||
|
InputResult::Submitted(text) => assert_eq!(text, "1あ"),
|
||||||
|
_ => panic!("expected Submitted"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn handle_paste_small_inserts_text() {
|
fn handle_paste_small_inserts_text() {
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
|
|||||||
@@ -198,12 +198,15 @@ impl PasteBurst {
|
|||||||
|
|
||||||
/// Before applying modified/non-char input: flush buffered burst immediately.
|
/// Before applying modified/non-char input: flush buffered burst immediately.
|
||||||
pub fn flush_before_modified_input(&mut self) -> Option<String> {
|
pub fn flush_before_modified_input(&mut self) -> Option<String> {
|
||||||
if self.is_active() {
|
if !self.is_active() {
|
||||||
self.active = false;
|
return None;
|
||||||
Some(std::mem::take(&mut self.buffer))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
self.active = false;
|
||||||
|
let mut out = std::mem::take(&mut self.buffer);
|
||||||
|
if let Some((ch, _at)) = self.pending_first_char.take() {
|
||||||
|
out.push(ch);
|
||||||
|
}
|
||||||
|
Some(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear only the timing window and any pending first-char.
|
/// Clear only the timing window and any pending first-char.
|
||||||
|
|||||||
Reference in New Issue
Block a user