Skip to content

Enable Shift-Insert to paste primary clipboard on Linux, fixes #36170.#63374

Merged
alexdima merged 5 commits intomicrosoft:masterfrom
sameer:sameer/36170
Jan 14, 2020
Merged

Enable Shift-Insert to paste primary clipboard on Linux, fixes #36170.#63374
alexdima merged 5 commits intomicrosoft:masterfrom
sameer:sameer/36170

Conversation

@sameer
Copy link
Contributor

@sameer sameer commented Nov 18, 2018

This PR fixes #36170 -- the Shift-Insert key combo will paste the primary clipboard as expected on Linux.

I also removed code related to using the mouse middle-click to paste the primary clipboard because it actually did nothing. clipboard.readText('selection') just reads the text, it does not generate a paste event as the comment originally on line 55 suggests. Pasting the primary clipboard with middle-mouse works out-of-the-box as far as I can tell.

@msftclas
Copy link

msftclas commented Nov 18, 2018

CLA assistant check
All CLA requirements met.

@Tyriar Tyriar assigned alexdima and unassigned Tyriar Dec 10, 2018
@alexdima alexdima added the linux Issues with VS Code on Linux label Dec 17, 2018
@sameer
Copy link
Contributor Author

sameer commented Aug 12, 2019

Hi @alexandrudima , just wondering if you have had a chance to look at this yet.

@sameer
Copy link
Contributor Author

sameer commented Nov 19, 2019

Hi @alexandrudima, when you have some time could you please take a look at this PR? Thank you.

@perlun
Copy link

perlun commented Jan 3, 2020

@Tyriar @bpasero Any chance you could help getting someone to review this? It seems to have been floating around for very long, so would be great to get it reviewed & hopefully merged anytime soon.

@Tyriar
Copy link
Member

Tyriar commented Jan 3, 2020

@perlun @alexdima is probably the only one who can sign off on this one.

if (e.equals(KeyMod.Shift | KeyCode.Insert)) {

I will say though that the current implementation probably isn't good enough as it hardcodes shift+insert instead of registering a custom keybinding.

@alexdima alexdima added this to the January 2020 milestone Jan 14, 2020
@alexdima
Copy link
Member

Thank you!

@evs-xsarus
Copy link

The behavior having SHIFT + INS pasting the now set clipboard fails when wanting to replace a piece of text. Done by first selecting that text. As I've never seen this behavior on linux before, I believe another shortcut for this keybinding should be better.

@perlun
Copy link

perlun commented Feb 12, 2020

The behavior having SHIFT + INS pasting the now set clipboard fails when wanting to replace a piece of text. Done by first selecting that text. As I've never seen this behavior on linux before, I believe another shortcut for this keybinding should be better.

It is true that it isn't present in all applications, but it exists in at least the following tools (terminal emulators):

  • xterm
  • Terminator

Some other tools use mouse button 2 (or middle button) for this. In IntelliJ it is configurable.

image


Anyway, if you dislike the new behavior, I suggest just overriding the keyboard bindings in this view. You can probably make Shift-Insert be an alias for the regular keyboard there as well if you like. (unsure if this can be done using the UI or if you have to hack the .json file in that case)

image

@vushe
Copy link

vushe commented Feb 18, 2020

This new behavior is super weird and confusing. I support @evs-xsarus, another key combination should be offered.

My current workaround:

~/.config/Code/User/keybindings.json

    {
        "key": "shift+insert",
        "command": "editor.action.clipboardPasteAction",
        "when": "textInputFocus && !editorReadonly"
    },

@Tyriar
Copy link
Member

Tyriar commented Feb 18, 2020

Shift+insert is acting as expected now. If you want it to paste from the regular clipboard (not primary) you should use the workaround.

@perlun
Copy link

perlun commented Feb 18, 2020

@vushe It's only weird for people used to Shift-Insert and Ctrl-V doing "the same thing", i.e. pasting from the clipboard (not from the primary selection). For people expecting these to do different things, the previous semantics felt odd.

Quoting @tobia in the original issue:

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

I am happy to see that VS Code has now moved to becoming a "traditional Linux program". 😉

However, I do sense that there is a bit of a storm of people disliking the new behavior, and it's up to you @Tyriar and others to decide. I like the new default, but I could live with the default being changed (given that it's easy to edit the preferences to switch back to the new mode anyway)

@Tyriar
Copy link
Member

Tyriar commented Feb 18, 2020

The old behavior was a bug imo, maybe we could add a FAQ to the linux docs if it is a common issue though.

@Tyriar
Copy link
Member

Tyriar commented Feb 18, 2020

Can see some people having problems in linked issues of #90222

@vushe
Copy link

vushe commented Feb 19, 2020

@perlun, yes it's pretty confusing when you updated program and in the middle of work process have to search in Google, what has happened with Shift+Insert. But good that VS Code now supports feature I have never heard about. It's ok, as I wrote, I found a workaround.

@Tyriar, Ctrl+Ins still copies text. I don't know if this is consistent, and from that perspective doubt it was a bug before.

In any case, this is just my opinion and I'm happy that everyone's happy.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

linux Issues with VS Code on Linux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

7 participants