Skip to content

TermControl: Remove the "hairpin" paste handler, consolidate string writers#20155

Open
DHowett wants to merge 6 commits intomainfrom
dev/duhowett/fhl-2026/remove-paste-hairpin-handler
Open

TermControl: Remove the "hairpin" paste handler, consolidate string writers#20155
DHowett wants to merge 6 commits intomainfrom
dev/duhowett/fhl-2026/remove-paste-hairpin-handler

Conversation

@DHowett
Copy link
Copy Markdown
Member

@DHowett DHowett commented Apr 29, 2026

This pull request rewrites how TermControl takes input from the outside world in a number of ways.

First, it introduces a new API called WriteInputString, which replaces both SendInput and PasteText. Those functions all had terrible and confusing names and semantics, but all boiled down to some internal implementation details around what was stripped where and how we added the bracketed paste sequence for clipboard content.

(For now, there is a duplicate WriteInputStringWithoutBroadcast which skips some of the loopy callback machinery; it is removed in #20165.)

Then, it removes the entire PasteFromClipboardEventArgs and its "callback" machinery for requesting a paste-if-you-would-just-please-call-me-back from the hosting application.

The connection is now 1:1: a control raises PasteRequested, and the host calls WriteInputString(..., Clipboard) to complete the transaction.

This also necessitated changing how we compute whether a paste would have been bracketed for the purpose of displaying warning dialogs and emitting empty paste packets. Now we check the control that originated the event (which required us to change how bubbled events report their sender.)

It might seem like I left weird stubs laying around.

In the future:

  1. StringSent can be totally removed, as paste content handling is already part of the app layer and drag/drop handling will be soon.
  2. anyHasBracketedPaste (and anyHasUnbracketedPaste) will grow to check every control in the "broadcast group" so that we warn appropriately when a paste will touch multiple controls in different encodings.

These changes allow us to localize paste encoding behavior to the control (rather than e.g. firing StringSent with a bracketed paste sequence to be consumed by a control that has bracketed paste turned off) and improve broadcast without weaving new and expensive event handlers up and down through the stack.

While doing this, I noticed that TSF composition doesn't get broadcasted... lol.

Comment thread src/cascadia/TerminalApp/TerminalPage.cpp Fixed
@DHowett
Copy link
Copy Markdown
Member Author

DHowett commented Apr 29, 2026

@github-actions

This comment has been minimized.

@DHowett DHowett force-pushed the dev/duhowett/fhl-2026/remove-paste-hairpin-handler branch from 36efc00 to 1b3aa5c Compare April 29, 2026 00:24
@github-actions

This comment was marked as resolved.

@DHowett DHowett force-pushed the dev/duhowett/fhl-2026/remove-paste-hairpin-handler branch from 1b3aa5c to ed93677 Compare April 30, 2026 00:15
@DHowett DHowett moved this to Cherry Picked in 1.24 Servicing Pipeline Apr 30, 2026
Copy link
Copy Markdown
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Really just the one thing I want to double check

// Return Value:
// - <none>
void TermControl::SendInput(const winrt::hstring& wstr)
void TermControl::WriteInputString(const winrt::hstring& wstr, WriteInputStringType type)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: update "Arguments" comment above to include type

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

frick i meant to murder the arguments section entirely

Comment on lines +3245 to +3240
_core.PasteText(text);
_core.WriteInputString(text, WriteInputStringType::Raw);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be WriteInputStringType::Clipboard?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. Yes

@DHowett DHowett changed the title TermControl: Remove the "hairpin" paste handler and all string writers TermControl: Remove the "hairpin" paste handler, consolidate string writers Apr 30, 2026
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.

3 participants