[PR #16480] Avoid generating extra formatted copies when no action specific copyFormatting is set #30932

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

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

State: closed
Merged: Yes


Avoid generating extra formatted copies when action's copyFormatting is not present and globally set copyFormatting is used.

Previously, when the action's copyFormatting wasn't set we deferred the decision of which formats needed to be copied to the TerminalPage::CopyToClipboard handler. This meant we needed to copy the text in all the available formats and pass it to the handler to copy the required formats after querying the global copyFormatting.

To avoid making extra copies, we'll store the global copyFormatting in TerminalSettings and pass it down to TermControl. If ControlCore::CopySelectionToClipboard() doesn't receive action specific copyFormatting, it will fall back to the global one before generating the texts.

Validation Steps Performed

  • no copyFormatting set for the copy action: Copies formats according to the global copyFormatting.
  • copyFormatting is set for the copy action: Copies formats according to the action's copyFormatting.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/16480 **State:** closed **Merged:** Yes --- Avoid generating extra formatted copies when action's `copyFormatting` is not present and globally set `copyFormatting` is used. Previously, when the action's `copyFormatting` wasn't set we deferred the decision of which formats needed to be copied to the `TerminalPage::CopyToClipboard` handler. This meant we needed to copy the text in all the available formats and pass it to the handler to copy the required formats after querying the global `copyFormatting`. To avoid making extra copies, we'll store the global `copyFormatting` in TerminalSettings and pass it down to `TermControl`. If `ControlCore::CopySelectionToClipboard()` doesn't receive action specific `copyFormatting`, it will fall back to the global one _before generating the texts_. ## Validation Steps Performed - no `copyFormatting` set for the copy action: Copies formats according to the global `copyFormatting`. - `copyFormatting` is set for the copy action: Copies formats according to the action's `copyFormatting`.
claunia added the pull-request label 2026-01-31 09:43: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#30932