[PR #15155] [MERGED] Add support for bracketed paste mode in ConHost #30452

Open
opened 2026-01-31 09:40:54 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/15155
Author: @j4james
Created: 4/10/2023
Status: Merged
Merged: 4/26/2023
Merged by: @DHowett

Base: mainHead: feature-bracketed-paste


📝 Commits (1)

  • edd20bd Support bracketed paste in conhost.

📊 Changes

10 files changed (+66 additions, -63 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.hpp (+1 -1)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+1 -1)
📝 src/host/consoleInformation.cpp (+10 -31)
📝 src/host/outputStream.cpp (+4 -8)
📝 src/host/outputStream.hpp (+1 -2)
📝 src/host/server.h (+17 -13)
📝 src/interactivity/win32/Clipboard.cpp (+27 -3)
📝 src/interactivity/win32/clipboard.hpp (+2 -1)
📝 src/terminal/adapter/ITerminalApi.hpp (+1 -1)
📝 src/terminal/adapter/ut_adapter/adapterTest.cpp (+2 -2)

📄 Description

This adds support for XTerm's "bracketed paste" mode in ConHost. When
enabled, any pasted text is bracketed with a pair of escape sequences,
which lets the receiving application know that the content was pasted
rather than typed.

References and Relevant Issues

Bracketed paste mode was added to Windows Terminal in PR #9034.
Adding it to ConHost ticks one more item off the list in #13408.

Detailed Description of the Pull Request / Additional comments

This only applies when VT input mode is enabled, since that is the way
Windows Terminal currently works.

When it comes to filtering, though, the only change I've made is to
filter out the escape character, and only when bracketed mode is
enabled. That's necessary to prevent any attempts to bypass the
bracketing, but I didn't want to mess with the expected behavior for
legacy apps if bracketed mode is disabled.

Validation Steps Performed

Manually tested in bash with bind 'set enable-bracketed-paste on' and
confirmed that pasted content is now buffered, instead of being executed
immediately.

Also tested in VIM, and confirmed that you can now paste preformatted
code without the autoindent breaking the formatting.

Closes #395


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/15155 **Author:** [@j4james](https://github.com/j4james) **Created:** 4/10/2023 **Status:** ✅ Merged **Merged:** 4/26/2023 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `feature-bracketed-paste` --- ### 📝 Commits (1) - [`edd20bd`](https://github.com/microsoft/terminal/commit/edd20bd0b4296c68f9a9fc3282ed07f1f86c78c7) Support bracketed paste in conhost. ### 📊 Changes **10 files changed** (+66 additions, -63 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+1 -1) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+1 -1) 📝 `src/host/consoleInformation.cpp` (+10 -31) 📝 `src/host/outputStream.cpp` (+4 -8) 📝 `src/host/outputStream.hpp` (+1 -2) 📝 `src/host/server.h` (+17 -13) 📝 `src/interactivity/win32/Clipboard.cpp` (+27 -3) 📝 `src/interactivity/win32/clipboard.hpp` (+2 -1) 📝 `src/terminal/adapter/ITerminalApi.hpp` (+1 -1) 📝 `src/terminal/adapter/ut_adapter/adapterTest.cpp` (+2 -2) </details> ### 📄 Description This adds support for XTerm's "bracketed paste" mode in ConHost. When enabled, any pasted text is bracketed with a pair of escape sequences, which lets the receiving application know that the content was pasted rather than typed. ## References and Relevant Issues Bracketed paste mode was added to Windows Terminal in PR #9034. Adding it to ConHost ticks one more item off the list in #13408. ## Detailed Description of the Pull Request / Additional comments This only applies when VT input mode is enabled, since that is the way Windows Terminal currently works. When it comes to filtering, though, the only change I've made is to filter out the escape character, and only when bracketed mode is enabled. That's necessary to prevent any attempts to bypass the bracketing, but I didn't want to mess with the expected behavior for legacy apps if bracketed mode is disabled. ## Validation Steps Performed Manually tested in bash with `bind 'set enable-bracketed-paste on'` and confirmed that pasted content is now buffered, instead of being executed immediately. Also tested in VIM, and confirmed that you can now paste preformatted code without the autoindent breaking the formatting. Closes #395 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:40:54 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30452