mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
## Why When terminals deliver pasted text as individual key events, tabs can trigger completion, submission, or queuing instead of preserving indentation in the draft. ## What changed Capture unmodified `Tab` events during paste bursts before shortcut dispatch, including after short Unicode prefixes. Refresh the burst idle timeout when appending tabs or newlines, and flush expired bursts before handling manual `Tab` shortcuts. ## Testing Add regression tests for multiline tab preservation, ASCII and Unicode prefixes, idle timeout refresh, completion suppression, and normal submission and queue shortcuts. Add a snapshot for pasted indentation. GitOrigin-RevId: ba404cfe66c23f37da5a0db7cccfdd3d4c4af331
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
//! Capture raw paste tabs before completion and submission shortcuts see them.
|
|
|
|
use super::*;
|
|
|
|
impl ChatComposer {
|
|
pub(super) fn handle_paste_tab(&mut self, key: KeyEvent, now: Instant) -> bool {
|
|
if key.code != KeyCode::Tab
|
|
|| !key.modifiers.is_empty()
|
|
|| self.draft.disable_paste_burst
|
|
|| !self.draft.textarea.allows_paste_burst()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
self.handle_paste_burst_flush(now);
|
|
if self
|
|
.draft
|
|
.paste_burst
|
|
.append_control_char_if_active('\t', now)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// Short non-ASCII prefixes are inserted directly, without a held first character.
|
|
if self
|
|
.draft
|
|
.paste_burst
|
|
.direct_insert_newline_should_insert(now)
|
|
{
|
|
self.draft
|
|
.paste_burst
|
|
.begin_with_retro_grabbed(String::new(), now);
|
|
return self
|
|
.draft
|
|
.paste_burst
|
|
.append_control_char_if_active('\t', now);
|
|
}
|
|
|
|
false
|
|
}
|
|
}
|