Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix image drag drop (#5794)

zhao-oai4d6a42a62288
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index 7b4d2f7ec4..8691b5b127 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -573,6 +573,16 @@ impl ChatComposer {
#[inline]
fn handle_non_ascii_char(&mut self, input: KeyEvent) -> (InputResult, bool) {
+ if let KeyEvent {
+ code: KeyCode::Char(ch),
+ ..
+ } = input
+ {
+ let now = Instant::now();
+ if self.paste_burst.try_append_char_if_active(ch, now) {
+ return (InputResult::None, true);
+ }
+ }
if let Some(pasted) = self.paste_burst.flush_before_modified_input() {
self.handle_paste(pasted);
}
diff --git a/codex-rs/tui/src/bottom_pane/paste_burst.rs b/codex-rs/tui/src/bottom_pane/paste_burst.rs
index 33a02bdefa..49377cb21c 100644
--- a/codex-rs/tui/src/bottom_pane/paste_burst.rs
+++ b/codex-rs/tui/src/bottom_pane/paste_burst.rs
@@ -163,6 +163,18 @@ impl PasteBurst {
self.burst_window_until = Some(now + PASTE_ENTER_SUPPRESS_WINDOW);
}
+ /// Try to append a char into the burst buffer only if a burst is already active.
+ ///
+ /// Returns true when the char was captured into the existing burst, false otherwise.
+ pub fn try_append_char_if_active(&mut self, ch: char, now: Instant) -> bool {
+ if self.active || !self.buffer.is_empty() {
+ self.append_char_to_buffer(ch, now);
+ true
+ } else {
+ false
+ }
+ }
+
/// Decide whether to begin buffering by retroactively capturing recent
/// chars from the slice before the cursor.
///