[PR #17059] Allow copying with ANSI escape code control sequences #31102

Closed
opened 2026-01-31 09:45:08 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17059

State: closed
Merged: Yes


Summary of the Pull Request

This extends the copy command to be able to include control sequences, for use in tools that subsequently know how to parse and display that.

References and Relevant Issues

https://github.com/microsoft/terminal/issues/15703

Detailed Description of the Pull Request / Additional comments

At a high level, this:

  • Expands the CopyTextArgs to have a withControlSequences bool.
  • Plumbs that bool down through many layers to where we actuall get data out of the text buffer.
  • Modifies the existing TextBuffer::Serialize to be more generic and renames it to TextBuffer::ChunkedSerialize.
  • Uses the new ChunkedSerialize to generate the data for the copy request.

Validation Steps Performed

To test this I've manually:

  • Generated some styled terminal contents, copied it with the control sequences, pasted it into a file, cated the file and seen that it looks the same.
  • Set "firstWindowPreference": "persistedWindowLayout" and validated that the contents of windows are saved and restored with styling intact.

I also checked that Invoke-OpenConsoleTests passed.

PR Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17059 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This extends the copy command to be able to include control sequences, for use in tools that subsequently know how to parse and display that. ## References and Relevant Issues https://github.com/microsoft/terminal/issues/15703 ## Detailed Description of the Pull Request / Additional comments At a high level, this: - Expands the `CopyTextArgs` to have a `withControlSequences` bool. - Plumbs that bool down through many layers to where we actuall get data out of the text buffer. - Modifies the existing `TextBuffer::Serialize` to be more generic and renames it to `TextBuffer::ChunkedSerialize`. - Uses the new `ChunkedSerialize` to generate the data for the copy request. ## Validation Steps Performed To test this I've manually: - Generated some styled terminal contents, copied it with the control sequences, pasted it into a file, `cat`ed the file and seen that it looks the same. - Set `"firstWindowPreference": "persistedWindowLayout"` and validated that the contents of windows are saved and restored with styling intact. I also checked that `Invoke-OpenConsoleTests` passed. ## PR Checklist - [x] Closes #15703 - [ ] Tests added/passed - [x] Documentation updated - If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: https://github.com/MicrosoftDocs/terminal/pull/756 - [x] Schema updated (if necessary)
claunia added the pull-request label 2026-01-31 09:45:08 +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#31102