Copy text without dismissing the selection #19890

Open
opened 2026-01-31 06:56:28 +00:00 by claunia · 0 comments
Owner

Originally created by @zadjii-msft on GitHub (May 17, 2023).

In Notepad, if there is a selection, pressing Ctrl+C, the text will be copied to the clipboard, otherwise nothing happens. This is the same in other edit boxes and controls
...
I would like Terminal/PowerShell to behave exactly like Notepad

This seems like a reasonable property to add to the copy action.

class CopyActionArgs {
  singleLine: bool = false;
  copyFormatting = false;
  dismissSelection: bool = false;
}

Originally suggested by @gaberiel44 in https://github.com/microsoft/terminal/discussions/15349

Note

Walkthrough

  • Add a Boolean DismissSelection to CopyTextArgs in src\cascadia\TerminalSettingsModel\ActionArgs.idl
  • Add DismissSelection to COPY_TEXT_ARGS in ActionArgs.h
  • The actual copy args are retrieved in TerminalPage::_HandleCopyText (in AppActionHandlers.cpp), and passed to TerminalPage::_CopyText, which calls down to TermControl::CopySelectionToClipboard.
    • In CopySelectionToClipboard, just don't ClearSelection.
  • This arg will also need localization, in ActionArgs.cpp, CopyTextArgs::GenerateName, and src\cascadia\TerminalSettingsModel\Resources\en-US\Resources.resw
Originally created by @zadjii-msft on GitHub (May 17, 2023). > In Notepad, if there is a selection, pressing Ctrl+C, the text will be copied to the clipboard, otherwise nothing happens. This is the same in other edit boxes and controls > ... > I would like Terminal/PowerShell to behave exactly like Notepad This seems like a reasonable property to add to the `copy` action. ```ts class CopyActionArgs { singleLine: bool = false; copyFormatting = false; dismissSelection: bool = false; } ``` _Originally suggested by @gaberiel44 in https://github.com/microsoft/terminal/discussions/15349_ > **Note** > ## Walkthrough * Add a `Boolean DismissSelection` to `CopyTextArgs` in `src\cascadia\TerminalSettingsModel\ActionArgs.idl` * Add `DismissSelection` to `COPY_TEXT_ARGS` in `ActionArgs.h` * The actual copy args are retrieved in `TerminalPage::_HandleCopyText` (in `AppActionHandlers.cpp`), and passed to `TerminalPage::_CopyText`, which calls down to `TermControl::CopySelectionToClipboard`. * In `CopySelectionToClipboard`, just don't `ClearSelection`. * This arg will also need localization, in `ActionArgs.cpp`, `CopyTextArgs::GenerateName`, and `src\cascadia\TerminalSettingsModel\Resources\en-US\Resources.resw`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19890