Preserve tabs in non-bracketed paste bursts (#45454)

## 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
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-14 16:05:17 +00:00
1 parent 4d8eca1ff3
commit 7a48b95c6c
6 files changed
+231 -12

No files matched your search

@@ -0,0 +1,41 @@
//! 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
}
}