Release v2.2.1#5346
Merged
Merged
Conversation
Enable terminal bracketed-paste mode (CSI ?2004h) at startup so the terminal wraps pasted content with ESC[200~ / ESC[201~ markers. The AnsiResponseParser detects the start marker, switches into a paste- collection state that buffers raw bytes (including escapes and newlines) until the end marker, then raises a Paste event carrying the stripped payload. The event flows: AnsiResponseParser.Paste -> InputProcessor.Paste -> IDriver.Paste -> Application.Paste, then dispatches to the focused view via View.NewPasteEvent (CWP-style virtual OnPasted, then Pasted event, then bubble to SuperView). TextField and TextView override OnPasted to insert the pasted text at the insertion point unless they are read-only. Falls back gracefully on terminals that don't support 2004h: the markers never arrive, so paste events never fire and pasted text is delivered through the normal key pipeline as before.
- Concurrency: move paste-buffer reset inside _lockState in AnsiResponseParserBase.ResetState. Previously the StringBuilder Clear() raced against ProcessInput's Append(). - Stranded pastes: add FlushStaleBracketedPaste on the parser and a 5-second idle check in InputProcessorImpl.ProcessQueue. Without it a dropped end marker would leave the parser holding pasted bytes forever and silently swallowing all subsequent input. - Dispatch: drop the TopRunnableView fallback in ApplicationImpl.RaisePasteEvent. If nothing has focus, the paste is not silently dropped into a non-text container — the Application Paste event still fires so apps can handle it explicitly. - Sanitization: TextField.OnPasted now takes only the first line and strips C0/C1 control chars, matching the existing clipboard Paste command and Windows Terminal's FilterStringForPaste. TextView normalizes \r and \r\n to \n and strips control chars except tab and newline. Application.Paste still delivers the raw payload — the sanitization is in the widget defaults so apps that subscribe directly retain full control. - Tests: parametric tests for start- and end-marker splits at every byte boundary, back-to-back pastes, nested literal start markers in the body, mid-paste reset, and the new flush API. - Docs: docfx/docs/bracketed-paste.md covering the user model, defaults, sanitization rules, and security considerations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Route bracketed paste through the existing Command.Paste pipeline instead of a parallel View.NewPasteEvent / OnPasted / Pasted dispatch path. - Default Command.Paste handler on View resolves payload (ctx.Value as string, else App.Clipboard), calls OnSanitizingPaste, raises cancellable Pasting (with mutable Text), calls OnPaste, raises Pasted. - Application.RaisePasteEvent now dispatches via InvokeCommand(Command.Paste, ctx.WithValue(text)); bubbling, cancellation, and Handled semantics come from the existing Command pipeline. - TextField and TextView override only OnSanitizingPaste (first-line strip / CR-LF normalize) and OnPaste (insertion). Their public Paste() methods now forward to InvokeCommand(Command.Paste) so Ctrl+V and bracketed paste share one path. - ReadOnly views return true from OnPaste so Ctrl+V does not bubble to a parent that might bind paste, matching legacy behavior. - Adds PastingEventArgs (mutable Text, cancellable) and PastedEventArgs (observation only). PasteEventArgs continues to carry the raw payload at the Application.Paste boundary. Addresses review feedback from @tig (no ViewBase sanitizer; no Command.Paste linkage) and @BDisp (virtual + event-with-same-value + bool return). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Back-merge v2.2.0 from main into develop
Fixes #5144. Add bracketed-paste mode support
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1a8eccfe1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This was referenced May 21, 2026
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release v2.2.1
Version:
2.2.1NuGet Package:
Terminal.Gui 2.2.1What happens when this PR is merged
v2.2.1main→developwill be openedChecklist
2.2.1