Skip to content

feat(input): insert terminal paste as one literal edit - #179

Merged
owainlewis merged 2 commits into
mainfrom
codex/issue-165-terminal-paste
Sep 8, 2026
Merged

feat(input): insert terminal paste as one literal edit#179
owainlewis merged 2 commits into
mainfrom
codex/issue-165-terminal-paste

Conversation

@owainlewis

@owainlewis owainlewis commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Terminal paste now arrives as one literal edit, preserving tabs, line endings, Unicode, and control characters without invoking key bindings or automatic indentation. Editable prompts flatten line breaks and tabs, discard other controls, and wait for an actual Enter; pasted text cannot confirm a dirty quit.
Empty paste also cancels a pending key prefix without changing text or history.

Bracketed paste is enabled during terminal setup and disabled during cleanup, including a failed setup flush. Terminal integration coverage checks exact saved bytes, one undo, and cleanup across existing exit paths.

Validation: formatting, strict all-target Clippy, release build, 360 unit tests, and the new PTY paste test pass locally. Ten of twelve terminal integration tests pass locally; the two existing redirected-input tests remain sandbox-restricted and require the full macOS CI run. A release PTY smoke passed literal paste, undo/redo, command and file prompts, dirty-quit isolation, and shell restoration. Fresh independent review approved with no findings.

Closes #165.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds literal bracketed-paste handling throughout the terminal editor.

  • Inserts nonempty editor paste as one undoable edit while preserving tabs, line endings, Unicode, and control characters.
  • Sanitizes pasted text for command, file, and buffer prompts without submitting them.
  • Prevents paste from confirming dirty quit and clears pending key prefixes, including for empty paste.
  • Enables bracketed paste during terminal setup and disables it during cleanup and partial setup failure.
  • Adds focused unit and PTY integration coverage for insertion, undo, prompt handling, prefix cancellation, rendering safety, and terminal restoration.

Confidence Score: 5/5

The PR appears safe to merge; the prior empty-paste prefix issue is fixed and no new actionable failures remain.

Empty editor paste now resets the keymap and clears prefix status, while every directory-picker paste is routed through the unhandled-key path. The roadmap thread was manually resolved after owainlewis explained that issue #164 had already shipped in the base commit and issue #165 remains open until this PR merges.

Important Files Changed

Filename Overview
src/app.rs Routes paste events by editor state, performs literal single-edit insertion, sanitizes prompt paste, and clears pending prefixes.
src/input.rs Adds single-line paste normalization that collapses CRLF and replaces supported line separators and tabs while dropping other controls.
src/terminal.rs Enables bracketed paste during setup and records the cleanup obligation before a potentially failing flush.
src/renderer.rs Adds coverage confirming literal pasted control characters are sanitized before terminal rendering.
tests/signal_cleanup.rs Adds PTY coverage for literal paste, one-step undo, empty-paste prefix cancellation, and paste-mode cleanup.

Reviews (2): Last reviewed commit: "fix(input): cancel key prefixes on empty..." | Re-trigger Greptile

Comment thread src/app.rs Outdated
Comment thread docs/roadmap.md
@owainlewis
owainlewis merged commit ebc53d2 into main Sep 8, 2026
2 checks passed
@owainlewis
owainlewis deleted the codex/issue-165-terminal-paste branch September 8, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert terminal paste literally as one edit

1 participant