Skip to content

Commit cb34642

Browse files
author
Stefan
committed
fix(cli): smart paste — 6 review fixes from PR #4764 feedback
Six bugs identified during PR #4764 review, applied as an atomic commit: 1. DRY _make_paste_marker() helper — all 3 call sites (handle_paste, _on_text_changed, _reconstruct_pastes) now share one canonical function, eliminating the char vs line format mismatch that broke paste reconstruction. 2. MAX_PASTE_SIZE = 100_000 memory cap — pastes > 100 KB are inserted as plain text to prevent OOM from hoarding oversized payloads. 3. Deletion loop: remove early return — replaced with any_deleted flag so every active paste_id is checked per keystroke; one Delete can now clear multiple stale markers instead of stopping at the first match. 4. Fallback: store pasted_portion not full buffer — _on_text_changed now saves text[prev_len:] (the newly pasted chunk) rather than buf.text in its entirety, so pre-existing typed content is never hoisted into the paste store. 5. Unified _PASTE_MARKER_RE regex — _reconstruct_pastes uses a single regex matching both [+X line(s)] and [+X char(s)] formats, making it robust against any inconsistency between the bracketed-paste path and the fallback detection path. 6. Threshold aligned to 20 chars — both handle_paste and _on_text_changed now use char_count >= 20 as the collapse trigger, consistent with the documented contract.
1 parent e85a0f3 commit cb34642

1 file changed

Lines changed: 1040 additions & 270 deletions

File tree

0 commit comments

Comments
 (0)