Skip to content

Option to not clear selection on copy #3884

Closed

Description

@owenneil

Description of the new feature/enhancement

Currently when you copy text it clears your selection. While this is current behavior for some terminals, this is different than standard Windows behavior. Most Windows programs simply leave the text selected and require some other action to deselect the text. This is particularly bad if you have remapped Copy to Ctrl-C, then accidentally hitting it twice can result in killing your running process accidentally. Additionally, I frequently will copy text, then need to come back to it later to recopy, but due to this issue I have to re-select the text frequently.

I just want copy/paste to work the same here that it does in every other program.

Activity

  1. added
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    on Dec 8, 2019
  2. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Dec 8, 2019
  3. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Dec 8, 2019
  4. DHowett-MSFT commented on Dec 9, 2019

    @DHowett-MSFT
    Contributor

    This is particularly bad if you have remapped Copy to Ctrl-C,

    Incidentally, the collision between copy and cancel (one of which is handled by the terminal emulator, and the other of which is handled by the remote application) is why we haven't bound Ctrl+C by default.

    There's a lot of different feature requests around copying, and people have a lot of different requirements here. We should converge them, if possible.

  5. added
    Area-TerminalControlIssues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.)
    Issue-TaskIt's a feature request, but it doesn't really need a major design.
    and removed
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Dec 9, 2019
  6. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Dec 9, 2019
  7. carlos-zamora commented on Jun 5, 2020

    @carlos-zamora

    Just thinking out loud. Here's a few thoughts:

    • what kinds of setting should this be? Keybinding arg? Global? Profile?
      • Like copyOnSelect, I feel that this should be a global setting
    • type should definitely be bool
    • we should keep ESC as a way to clear the selection
    • passing key events to the Terminal should also clear the selection as they do now
    • what's a nice name for this?
      • persistSelectionOnCopy (default is false)

    Originally thought of naming it clearSelectionOnCopy (default is true), but I've been told before that we should try and make the default false. So any thoughts as to what this setting could be called is much appreciated :) (for now I'm just going with the plan above).

    EDIT: alternatively, persistentSelection or persistSelection? slightly shorter

  8. 4 remaining items

  9. zadjii-msft commented on Jul 6, 2022

    @zadjii-msft
    Member

    From #13438

    Should be fairly trivial to add a dismissSelection property to the copy action, defaults to true, and does what you'd expect. We should then change the enter keybinding to

            { "command": { "action": "copy", "singleLine": false, "dismissSelection": false }, "keys": "enter" },

    er... maybe we don't change the defaults. Those would be the opposite of ConEmu

  10. added
    Help WantedWe encourage anyone to jump in on these.
    good first issueThis is a fix that might be easier for someone to do as a first contribution
    on Jul 6, 2022
  11. vladisaev12 commented on Nov 19, 2025

    @vladisaev12

    Here's a question:

    if persistSelection is enabled, and a selection is active, what should we expect right-click to do?

    1. copy the selected text?
    
    2. paste what is on the clipboard?
    
    3. copy the selected text and paste what is on the clipboard? --> `copyOnSelect`
    

    You could take the linux approach:

    (in pseudo-code)

    if(currentSelection != newSelection and !newSelection.IsEmpty()) {
        PutToClipboard(newSelection);
    } elif(!newSelection.IsEmpty()) {
        PasteFromClipboard(currentSelection);
    }    
    
  12. Jotanune commented on Apr 5, 2026

    @Jotanune

    Hi, I'm looking to make my first contribution to the terminal and I'd love to pick up this issue. I plan to follow Mike Griese (@zadjii-msft) 's approach from 2022: adding a dismissSelection boolean property to the copy action (defaulting to true to preserve current behavior). Could you assign this to me?

  13. DHowett commented on Apr 5, 2026

    @DHowett
    Member

    Javier Núñez (@Jotanune) we do not assign bugs to first-time contributors. Most of them do not come back. Fortunately, you do not need to be assigned a bug to work on it! :)

  14. Jotanune commented on Apr 6, 2026

    @Jotanune

    @Jotanune we do not assign bugs to first-time contributors. Most of them do not come back. Fortunately, you do not need to be assigned a bug to work on it! :)

    Understood, that makes total sense. I'll start working on it locally and will open a Draft PR as soon as I have the basic logic implemented so you can see the progress.

  15. Jotanune commented on Apr 6, 2026

    @Jotanune

    Hey Dustin L. Howett (@DHowett) , while digging into the codebase to start implementing this, I found out that this feature is actually already implemented. It looks like it was merged back in July 2023 in PR #15552 (which closed the duplicate issue #15371). The dismissSelection property is already present in CopyTextArgs and working as intended. It seems this issue was just left open by mistake because the PR referenced the duplicate instead of this one. I'll go hunt for another good first issue from the backlog to work on. Cheers!

  16. DHowett commented on Apr 6, 2026

    @DHowett
    Member

    Wow, good find! Thanks so much.

    /dup #15371

  17. microsoft-github-policy-service commented on Apr 6, 2026

    @microsoft-github-policy-service
    Contributor

    Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-TerminalControlIssues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.)Help WantedWe encourage anyone to jump in on these.Issue-TaskIt's a feature request, but it doesn't really need a major design.Priority-2A description (P2)Product-TerminalThe new Windows Terminal.Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.good first issueThis is a fix that might be easier for someone to do as a first contribution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions