Vscode: Shift-insert should insert the PRIMARY clipboard on Linux, not the CLIPBOARD clipboard

Created on 12 Oct 2017  路  15Comments  路  Source: microsoft/vscode

  • VSCode Version:

Version 1.16.1
Commit 27492b6bf3acb0775d82d2f87b25a93490673c6d
Date 2017-09-14T16:26:20.018Z
Shell 1.7.3
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

  • OS Version:
    Linux dv 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Steps to Reproduce:

  1. Select some text with the mouse. This puts it in the PRIMARY clipboard.
  2. Press Shift+Insert.

In well-behaved Linux applications, this will paste in the text you just selected. In vscode, however, it pastes in the text in the CLIPBOARD clipboard. To insert the text in the PRIMARY clipboard, you must precisely position the mouse cursor and middle-click.

https://wiki.archlinux.org/index.php/clipboard


Reproduces without extensions: Yes/No

editor-clipboard feature-request help wanted linux verification-needed verified

Most helpful comment

Regardless of what the correct behavior is, I'd like to have an editor action for "paste primary clipboard" so that I can configure this myself.

All 15 comments

+1, I miss this feature too.

To play the devil's advocate, "well-behaved Linux applications" are far and between nowadays.

Most applications, including all modern GTK apps and browsers, consider Shift+Insert as equivalent to Ctrl+V, probably to cater to Windows people who are used to that shortcut and are not accustomed to the concept of a dual clipboard.

That being said, terminal emulators and traditional Linux programs do make the distinction and developers and hackers make regular use of it.

As a comparison, Sublime Text has the same (broken) behavior by default (Shift+Ins = Ctrl+V) but allows changing it through the keybindings:

{"keys": ["shift+insert"], "command": "paste", "args": {"clipboard": "selection"}},

Regardless of what the correct behavior is, I'd like to have an editor action for "paste primary clipboard" so that I can configure this myself.

FWIW - IntelliJ also has the same (broken and incorrect) behavior but can easily be dressed to act differently:

image

Note the difference between the "Paste" and "Paste from X Clipboard" actions; the latter is the missing functionality in VS Code at the moment.

@Tyriar @rebornix Any updates on this? It's really frustrating to not be able to paste from the primary selection with keyboard. Right now, I have "solved" this by binding Shift-Insert to /usr/bin/xdotool click 2 in my GNOME settings, but the problem with that approach is that it will paste the content _where the mouse cursor is located_ - not where the _text_ cursor is located. So, a hack that doesn't fully work... :cry:

@rebornix would we accept a PR to add a command to paste from the PRIMARY clipboard?

@Tyriar if it's a standard/common linux behavior, an additional command for that is a good solution to me. If that's the case, can you provide some guidance about how to access this PRIMARY clipboard? The command can go into https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/clipboard/clipboard.ts .

I'm not sure how to access the primary clipboard in node, but I'm sure it's possible. This is a good candidate for a community PR imo.

Also the command should only be registered on Linux.

Does this help?

https://github.com/electron/electron/issues/377

Now clipboard.readText('selection') reads the selection clipboard.

Anyone interested in fixing this? The current behavior is quite annoying for us Linux users.

I tried using clipboard synchronization using Parcellite (http://parcellite.sourceforge.net/), which is a nice tool for maintaining clipboard history also btw, and it _works_ but has the significant downside of making it very easy to overwrite your Ctrl-V clipboard by accident. (you just select some text in VSCode and bam, overwritten) So, it's not really optimal.

Please, please anyone. :smile:

Sorry, meant to post this yesterday -- I am looking into this.
Copy/paste/cut seems to be done with Document.execCommand() in src/vs/editor/contrib/clipboard/clipboard.ts.
@tobia is right I think, but I am not sure if it is appropriate to import Electron in this context, since it references browsers.

Ok, I have a fix that allows Shift + Insert to paste the primary clipboard. Once I refactor it so the vscode standards are followed, I should be able to do a PR.

It seems that middle-click is also a primary clipboard paste trigger, but I am not sure how to enable that yet.

Edit: Middle-click seems to work out of the box?

Edit: Middle-click seems to work out of the box?

Middle-click works now already, yes, in the stable version of vscode.

Edit: Middle-click seems to work out of the box?

Middle-click works now already, yes, in the stable version of vscode.

Good to hear -- I have a touchpad and it works when I click both left and right at the same time, wasn't sure about middle-click for mouse users.

Thank you @sameer for your contribution.

Today marks 1 year since the pull request was submitted. Which animal do you think we need to sacrifice for this request to be considered?

There are some conflicts to resolve before merging since it's been so long, I will get to those hopefully sometime this week. Once I've done those I will ask for a review again.

Edit: PR is ready

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shanalikhan picture shanalikhan  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

sijad picture sijad  路  3Comments

curtw picture curtw  路  3Comments

biij5698 picture biij5698  路  3Comments