terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Option to not clear selection on copy

Open owenneil opened this issue 6 years ago • 6 comments

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.

owenneil avatar Dec 08 '19 08:12 owenneil

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.

DHowett-MSFT avatar Dec 09 '19 20:12 DHowett-MSFT

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

carlos-zamora avatar Jun 05 '20 21:06 carlos-zamora

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

This makes me wonder if maybe a global setting isn't the right approach, and instead there should be a keybinding arg on 'copy'. Then, this could work more like a text editor, where...

  • you make a selection
  • you copy with your keybinding (selection persists)
  • you paste (selection gets cleared because text got sent to the terminal)

The only thing I dislike is that a user would have to add this keybinding arg to all of their copy keybindings. But, I think that's a small case with a minor annoyance.

carlos-zamora avatar Jun 05 '20 22:06 carlos-zamora

I feel like #9787 is related

YAMLcase avatar Apr 14 '21 15:04 YAMLcase

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

zadjii-msft avatar Jul 06 '22 10:07 zadjii-msft

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);
}    

vladisaev12 avatar Nov 19 '25 17:11 vladisaev12