Skip to content

Release v2.2.1#5346

Merged
tig merged 8 commits into
mainfrom
release/v2.2.1
May 19, 2026
Merged

Release v2.2.1#5346
tig merged 8 commits into
mainfrom
release/v2.2.1

Conversation

@tig

@tig tig commented May 19, 2026

Copy link
Copy Markdown
Member

Release v2.2.1

Version: 2.2.1
NuGet Package: Terminal.Gui 2.2.1

What happens when this PR is merged

  1. ✅ The Finalize Release workflow will automatically create tag v2.2.1
  2. ✅ The Publish workflow will build and push to NuGet.org
  3. ✅ A GitHub Release will be created with auto-generated notes
  4. ✅ A back-merge PR from maindevelop will be opened

Checklist

  • CI passes on this PR
  • Version looks correct: 2.2.1
  • Release notes reviewed (will be auto-generated on merge)

harder and others added 8 commits May 15, 2026 17:27
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread Terminal.Gui/Views/TextInput/TextView/TextView.Text.cs
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.

2 participants