New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux middle mouse paste inserts text twice #8648

Closed
cloos opened this Issue Sep 3, 2015 · 59 comments

Comments

Projects
None yet
@cloos

cloos commented Sep 3, 2015

  • mark somewhere text with the mouse
  • File -> New File
  • press middle mouse button to insert text

The text is inserted twice.

This happens since 1.0.8 and even in the latest 1.0.10.

atom-amd64.deb
Ubuntu 15.04

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 3, 2015

I think that behavior has been there for much longer, since I first tried Atom (0.180).

Here is a solution.

I recommend you to apply this patch in the package source file (sublime-select.coffee):

  when 'win32'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 2
    enableMiddleMouse: true
  when 'darwin'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 2
    enableMiddleMouse: true
  when 'linux'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 1
    enableMiddleMouse: false
  else
    selectKey: 'altKey'
    mainMouseNum: 2
    middleMouseNum: 2
    enableMiddleMouse: false

It also lets you do line selection a la Sublime with Alt + Shift + right-click.

ghost commented Sep 3, 2015

I think that behavior has been there for much longer, since I first tried Atom (0.180).

Here is a solution.

I recommend you to apply this patch in the package source file (sublime-select.coffee):

  when 'win32'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 2
    enableMiddleMouse: true
  when 'darwin'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 2
    enableMiddleMouse: true
  when 'linux'
    selectKey: 'altKey'
    mainMouseNum: 1
    middleMouseNum: 1
    enableMiddleMouse: false
  else
    selectKey: 'altKey'
    mainMouseNum: 2
    middleMouseNum: 2
    enableMiddleMouse: false

It also lets you do line selection a la Sublime with Alt + Shift + right-click.

@cloos

This comment has been minimized.

Show comment
Hide comment
@cloos

cloos Sep 3, 2015

If I install 1.0.7, the text is inserted only once, so everything is fine.
The issue appeared since 1.0.8.

As this seams to be a core issue, I don't think installing a community package is a right solution.

Also I think that this wouldn't solve the issue, as by "mark somewhere text with the mouse" I mean mark text for example inside the browser, and not text inside the atom editor.

cloos commented Sep 3, 2015

If I install 1.0.7, the text is inserted only once, so everything is fine.
The issue appeared since 1.0.8.

As this seams to be a core issue, I don't think installing a community package is a right solution.

Also I think that this wouldn't solve the issue, as by "mark somewhere text with the mouse" I mean mark text for example inside the browser, and not text inside the atom editor.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 3, 2015

I couldn't reproduce this. It just pasted once (Select code, New File -> Middle button).

ghost commented Sep 3, 2015

I couldn't reproduce this. It just pasted once (Select code, New File -> Middle button).

@nicksanders

This comment has been minimized.

Show comment
Hide comment
@nicksanders

nicksanders Sep 4, 2015

I'm experiencing this too after upgrading from 1.0.7 to 1.0.11

nicksanders commented Sep 4, 2015

I'm experiencing this too after upgrading from 1.0.7 to 1.0.11

@dpanter

This comment has been minimized.

Show comment
Hide comment
@dpanter

dpanter Sep 9, 2015

Could not reproduce this issue with 1.0.11, fresh install.
Following OP instructions, it only pasted once.
Linux Mint Debian Edition, KDE4.

dpanter commented Sep 9, 2015

Could not reproduce this issue with 1.0.11, fresh install.
Following OP instructions, it only pasted once.
Linux Mint Debian Edition, KDE4.

@nicksanders

This comment has been minimized.

Show comment
Hide comment
@nicksanders

nicksanders Sep 18, 2015

This is still happening with Atom 1.0.13

To reproduce
mv ~/.atom ~/.atom-saved
atom --safe

In untitled tab
type "test" then press enter twice
double click left mouse button on test to highlight
move mouse to line 3 and click left mouse button and then press middle mouse button

atom1

If you don't click left mouse button before clicking the middle mouse button it pastes correctly

nicksanders commented Sep 18, 2015

This is still happening with Atom 1.0.13

To reproduce
mv ~/.atom ~/.atom-saved
atom --safe

In untitled tab
type "test" then press enter twice
double click left mouse button on test to highlight
move mouse to line 3 and click left mouse button and then press middle mouse button

atom1

If you don't click left mouse button before clicking the middle mouse button it pastes correctly

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 18, 2015

@nicksanders I can confirm this happens to me as well.

Linux 15.04 64-bits Atom 1.0.14

ghost commented Sep 18, 2015

@nicksanders I can confirm this happens to me as well.

Linux 15.04 64-bits Atom 1.0.14

@50Wliu 50Wliu added bug and removed needs-reproduction labels Sep 18, 2015

@dpanter

This comment has been minimized.

Show comment
Hide comment
@dpanter

dpanter Sep 19, 2015

@nicksanders I'll revise my earlier statement and say I can in fact reproduce this exact behavior as well, a left click before pasting with a middle click changes the result.

However... as I tried middle clicking more than once, I realized each subsequent middle click makes my 1.0.11 doubly paste what it just pasted. Preceding left click or not makes no difference.
I get "test" -> "testtest" -> "testtesttesttest" -> "testtesttesttesttesttesttesttest" -> "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" and so on.

Probably not the intended behavior.

dpanter commented Sep 19, 2015

@nicksanders I'll revise my earlier statement and say I can in fact reproduce this exact behavior as well, a left click before pasting with a middle click changes the result.

However... as I tried middle clicking more than once, I realized each subsequent middle click makes my 1.0.11 doubly paste what it just pasted. Preceding left click or not makes no difference.
I get "test" -> "testtest" -> "testtesttesttest" -> "testtesttesttesttesttesttesttest" -> "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" and so on.

Probably not the intended behavior.

@hainesr

This comment has been minimized.

Show comment
Hide comment
@hainesr

hainesr Oct 2, 2015

This is happening in version 1.0.19 (from the PPA) on Ubuntu 14.04 too.

hainesr commented Oct 2, 2015

This is happening in version 1.0.19 (from the PPA) on Ubuntu 14.04 too.

@slegga

This comment has been minimized.

Show comment
Hide comment
@slegga

slegga Oct 16, 2015

I also have this problem on Atom 1.0.19 kubuntu 15.04 32 bit.
If before pressing middle button I do a double right click, the middle button works with no extra paste.

slegga commented Oct 16, 2015

I also have this problem on Atom 1.0.19 kubuntu 15.04 32 bit.
If before pressing middle button I do a double right click, the middle button works with no extra paste.

@nicksanders

This comment has been minimized.

Show comment
Hide comment
@nicksanders

nicksanders Nov 3, 2015

This is still happening with Atom 1.1.0

nicksanders commented Nov 3, 2015

This is still happening with Atom 1.1.0

@JohnA3

This comment has been minimized.

Show comment
Hide comment
@JohnA3

JohnA3 Nov 13, 2015

Still here with Atom 1.3.0b1 on linux64

JohnA3 commented Nov 13, 2015

Still here with Atom 1.3.0b1 on linux64

@pedantic-git

This comment has been minimized.

Show comment
Hide comment
@pedantic-git

pedantic-git Nov 15, 2015

Agreed. Happening to me too with 1.2.0 official build (Ubuntu 15.10 64-bit).

pedantic-git commented Nov 15, 2015

Agreed. Happening to me too with 1.2.0 official build (Ubuntu 15.10 64-bit).

@jetole

This comment has been minimized.

Show comment
Hide comment
@jetole

jetole Dec 10, 2015

Is this issue still open or has it been resolved? I am experiencing this bug as well.

jetole commented Dec 10, 2015

Is this issue still open or has it been resolved? I am experiencing this bug as well.

@nicksanders

This comment has been minimized.

Show comment
Hide comment
@nicksanders

nicksanders Dec 10, 2015

Still happening to me as well
On 10 Dec 2015 5:13 p.m., "jetole" notifications@github.com wrote:

Is this issue still open or has it been resolved? I am experiencing this
bug as well.


Reply to this email directly or view it on GitHub
#8648 (comment).

nicksanders commented Dec 10, 2015

Still happening to me as well
On 10 Dec 2015 5:13 p.m., "jetole" notifications@github.com wrote:

Is this issue still open or has it been resolved? I am experiencing this
bug as well.


Reply to this email directly or view it on GitHub
#8648 (comment).

@50Wliu

This comment has been minimized.

Show comment
Hide comment
@50Wliu

50Wliu Dec 10, 2015

Member

Is this issue still open or has it been resolved?

It's still open.

Member

50Wliu commented Dec 10, 2015

Is this issue still open or has it been resolved?

It's still open.

@oetiker

This comment has been minimized.

Show comment
Hide comment
@oetiker

oetiker Dec 11, 2015

same here

oetiker commented Dec 11, 2015

same here

@hainesr

This comment has been minimized.

Show comment
Hide comment
@hainesr

hainesr Dec 11, 2015

Interestingly, Atom appears to be seeing this double paste as two separate operations; a single undo (ctrl-z) only removes the second one.

This has become my workaround but it would be nice to have this fixed.

hainesr commented Dec 11, 2015

Interestingly, Atom appears to be seeing this double paste as two separate operations; a single undo (ctrl-z) only removes the second one.

This has become my workaround but it would be nice to have this fixed.

@iivvoo

This comment has been minimized.

Show comment
Hide comment
@iivvoo

iivvoo Jan 11, 2016

Same problem here, very consistent (and very annoying). Atom 1.3.2 on Ubuntu 14.04 x64

But it doesn't always happen. Pastes on empty lines seem to go well but inside an existing line / piece of text usually results in double pastes.

iivvoo commented Jan 11, 2016

Same problem here, very consistent (and very annoying). Atom 1.3.2 on Ubuntu 14.04 x64

But it doesn't always happen. Pastes on empty lines seem to go well but inside an existing line / piece of text usually results in double pastes.

@jlsalvador

This comment has been minimized.

Show comment
Hide comment
@jlsalvador

jlsalvador Jan 18, 2016

I made an horrific-patch that prevents duplicates (I have not time to investigate the source):

diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee
index 430b0c0..4e08c49 100644
--- a/src/text-editor-component.coffee
+++ b/src/text-editor-component.coffee
@@ -34,6 +34,7 @@ class TextEditorComponent
   gutterComponent: null
   mounted: true
   initialized: false
+  lastPasteSelectionClipboardEvent: null

   Object.defineProperty @prototype, "domNode",
     get: -> @domNodeValue
@@ -638,8 +639,9 @@ class TextEditorComponent
       Math.pow(scrollDelta / 2, 3) / 280

     pasteSelectionClipboard = (event) =>
-      if event?.which is 2 and process.platform is 'linux'
+      if event?.which is 2 and process.platform is 'linux' and @lastPasteSelectionClipboardEvent != event
         if selection = require('./safe-clipboard').readText('selection')
+          @lastPasteSelectionClipboardEvent = event
           @editor.insertText(selection)

     window.addEventListener('mousemove', onMouseMove)

jlsalvador commented Jan 18, 2016

I made an horrific-patch that prevents duplicates (I have not time to investigate the source):

diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee
index 430b0c0..4e08c49 100644
--- a/src/text-editor-component.coffee
+++ b/src/text-editor-component.coffee
@@ -34,6 +34,7 @@ class TextEditorComponent
   gutterComponent: null
   mounted: true
   initialized: false
+  lastPasteSelectionClipboardEvent: null

   Object.defineProperty @prototype, "domNode",
     get: -> @domNodeValue
@@ -638,8 +639,9 @@ class TextEditorComponent
       Math.pow(scrollDelta / 2, 3) / 280

     pasteSelectionClipboard = (event) =>
-      if event?.which is 2 and process.platform is 'linux'
+      if event?.which is 2 and process.platform is 'linux' and @lastPasteSelectionClipboardEvent != event
         if selection = require('./safe-clipboard').readText('selection')
+          @lastPasteSelectionClipboardEvent = event
           @editor.insertText(selection)

     window.addEventListener('mousemove', onMouseMove)
@pedantic-git

This comment has been minimized.

Show comment
Hide comment
@pedantic-git

pedantic-git Jan 19, 2016

Related to this: I was looking at a package page under "Settings -> Updates" and I noticed that left-clicking "CHANGELOG" opened the changelog in two tabs, and clicking on the package address opened two tabs in my browser with the package page. I suspect it's connected.

pedantic-git commented Jan 19, 2016

Related to this: I was looking at a package page under "Settings -> Updates" and I noticed that left-clicking "CHANGELOG" opened the changelog in two tabs, and clicking on the package address opened two tabs in my browser with the package page. I suspect it's connected.

@rednil

This comment has been minimized.

Show comment
Hide comment
@rednil

rednil Jan 22, 2016

I am experiencing this as well in about 50% of the cases. However, I believe this is an ubuntu issue, since I see this in gvim as well, but NOT in the terminal, for example. It happened in 14.04, and it still happens in 15.10

rednil commented Jan 22, 2016

I am experiencing this as well in about 50% of the cases. However, I believe this is an ubuntu issue, since I see this in gvim as well, but NOT in the terminal, for example. It happened in 14.04, and it still happens in 15.10

@jperelli

This comment has been minimized.

Show comment
Hide comment
@jperelli

jperelli Jan 26, 2016

This happens to me too.
It happens when I click with left button to place the cursor and then with middle button to paste primary selection.
If I click middle button in other place where the cursor is not placed, it pastes only once.

jperelli commented Jan 26, 2016

This happens to me too.
It happens when I click with left button to place the cursor and then with middle button to paste primary selection.
If I click middle button in other place where the cursor is not placed, it pastes only once.

@person666

This comment has been minimized.

Show comment
Hide comment
@person666

person666 Jan 26, 2016

@rednil it is not an Ubuntu issue I get the issue on arch gnome and kde

person666 commented Jan 26, 2016

@rednil it is not an Ubuntu issue I get the issue on arch gnome and kde

@beastea

This comment has been minimized.

Show comment
Hide comment
@beastea

beastea Feb 4, 2016

Experiencing issue with pasting on middle button click on Fedora23 x86_64. It works for me fine with atom 1.4.0 version but completely breaks starting from 1.4.1

beastea commented Feb 4, 2016

Experiencing issue with pasting on middle button click on Fedora23 x86_64. It works for me fine with atom 1.4.0 version but completely breaks starting from 1.4.1

@dpanter

This comment has been minimized.

Show comment
Hide comment
@dpanter

dpanter Feb 4, 2016

Upgraded to 1.4.3 today. This is still broken.
However, if I move the mouse a bit between pasting, it only pastes once.

dpanter commented Feb 4, 2016

Upgraded to 1.4.3 today. This is still broken.
However, if I move the mouse a bit between pasting, it only pastes once.

@dietmar

This comment has been minimized.

Show comment
Hide comment
@dietmar

dietmar Feb 10, 2017

Contributor

Everyone, no hard feelings, but please stop adding comments like "I also have this issue" and "it annoys me", they are not helpful. This issue has been confirmed, it has received the label "bug" and also the label "help-wanted", so the situation is pretty clear: everyone is invited to contribute towards resolving the issue.

If people's inboxes get hammered with such meaningless comments, they will unsubscribe from this issue and it will be left entirely in the dark. So let's please stick to discussing the issue in the direction of actually resolving it.

Contributor

dietmar commented Feb 10, 2017

Everyone, no hard feelings, but please stop adding comments like "I also have this issue" and "it annoys me", they are not helpful. This issue has been confirmed, it has received the label "bug" and also the label "help-wanted", so the situation is pretty clear: everyone is invited to contribute towards resolving the issue.

If people's inboxes get hammered with such meaningless comments, they will unsubscribe from this issue and it will be left entirely in the dark. So let's please stick to discussing the issue in the direction of actually resolving it.

@sleeksorrow

This comment has been minimized.

Show comment
Hide comment
@sleeksorrow

sleeksorrow Feb 10, 2017

Sadly the person adding the "help-wanted" tag forgot to tell which kind of help is wanted. There is a clear reproduction scenario in the comments. Short version: 1) Mouse selection copy, 2) click in atom window, 3) mmb paste. Really it's that easy.

So the most obvious help people can provide is to tell that they are affected, so developers know that newer distribution versions did not fix the issue magically.

So if the developers need more help/info/money/coffee, we need clear directions. I'm happy to assist.

sleeksorrow commented Feb 10, 2017

Sadly the person adding the "help-wanted" tag forgot to tell which kind of help is wanted. There is a clear reproduction scenario in the comments. Short version: 1) Mouse selection copy, 2) click in atom window, 3) mmb paste. Really it's that easy.

So the most obvious help people can provide is to tell that they are affected, so developers know that newer distribution versions did not fix the issue magically.

So if the developers need more help/info/money/coffee, we need clear directions. I'm happy to assist.

@dietmar

This comment has been minimized.

Show comment
Hide comment
@dietmar

dietmar Feb 10, 2017

Contributor

@sleeksorrow the way forward is pretty obvious: all of the source code is openly available, and the problem has been described with sufficient detail; someone needs to dive into the problem, actually solve it, test the solution, and provide the code changes that fix the problem. In short, a pull request.

If you don't have time to do that, that's fine, but please understand that a thousand people saying "I want this fixed but I don't want to do it myself" doesn't move anything forward.

Contributor

dietmar commented Feb 10, 2017

@sleeksorrow the way forward is pretty obvious: all of the source code is openly available, and the problem has been described with sufficient detail; someone needs to dive into the problem, actually solve it, test the solution, and provide the code changes that fix the problem. In short, a pull request.

If you don't have time to do that, that's fine, but please understand that a thousand people saying "I want this fixed but I don't want to do it myself" doesn't move anything forward.

@sleeksorrow

This comment has been minimized.

Show comment
Hide comment
@sleeksorrow

sleeksorrow Feb 10, 2017

The pull request from @iivvoo is linked up there and is being ignored since one year now. I don't see any reason why I should make a duplicate pull request.

sleeksorrow commented Feb 10, 2017

The pull request from @iivvoo is linked up there and is being ignored since one year now. I don't see any reason why I should make a duplicate pull request.

@jlsalvador

This comment has been minimized.

Show comment
Hide comment

jlsalvador commented Feb 10, 2017

@50Wliu

This comment has been minimized.

Show comment
Hide comment
@50Wliu

50Wliu Feb 10, 2017

Member

That PR is distinctly labeled as a "workaround" and not an actual solution.

Member

50Wliu commented Feb 10, 2017

That PR is distinctly labeled as a "workaround" and not an actual solution.

@schlomo

This comment has been minimized.

Show comment
Hide comment
@schlomo

schlomo Mar 24, 2017

+1 Very annoying bug indeed.

schlomo commented Mar 24, 2017

+1 Very annoying bug indeed.

@sleeksorrow

This comment has been minimized.

Show comment
Hide comment
@sleeksorrow

sleeksorrow Mar 27, 2017

@dietmar I really appreciate your work on this issue. Thank you very much.

sleeksorrow commented Mar 27, 2017

@dietmar I really appreciate your work on this issue. Thank you very much.

ungb pushed a commit that referenced this issue Apr 4, 2017

Bryant Ung
Merge pull request #14063 from dietmar/linux_middle_mouse_8648
fixing middle mouse button clipboard paste on linux (atom:atom#8648)
@50Wliu

This comment has been minimized.

Show comment
Hide comment
@50Wliu

50Wliu Apr 4, 2017

Member

Thanks @dietmar for your initiative! The fix is scheduled to be released in Atom 1.17, soon to be in beta.

Member

50Wliu commented Apr 4, 2017

Thanks @dietmar for your initiative! The fix is scheduled to be released in Atom 1.17, soon to be in beta.

@50Wliu 50Wliu closed this Apr 4, 2017

@Asraelite

This comment has been minimized.

Show comment
Hide comment
@Asraelite

Asraelite Jun 27, 2017

This issue has appeared for me again in Atom 1.19.0.beta1-1, although it is not in 1.18.

Asraelite commented Jun 27, 2017

This issue has appeared for me again in Atom 1.19.0.beta1-1, although it is not in 1.18.

@hex007

This comment has been minimized.

Show comment
Hide comment
@hex007

hex007 Jul 5, 2017

I can affirm that that Atom 1.19.0.beta2 also has this bug

EDIT : @50Wliu Can you open this issue again.

hex007 commented Jul 5, 2017

I can affirm that that Atom 1.19.0.beta2 also has this bug

EDIT : @50Wliu Can you open this issue again.

@ungb

This comment has been minimized.

Show comment
Hide comment
@ungb

ungb Jul 6, 2017

Contributor

@nathansobo I think the refactor of text-editor-component.coffee -> text-editor-component.js might of cause this to regressed. can you take a look? I can repro this issue and can help you get a repro if needed.

Looking when the files changed and I found commit: f237d70

Contributor

ungb commented Jul 6, 2017

@nathansobo I think the refactor of text-editor-component.coffee -> text-editor-component.js might of cause this to regressed. can you take a look? I can repro this issue and can help you get a repro if needed.

Looking when the files changed and I found commit: f237d70

@xenadu000

This comment has been minimized.

Show comment
Hide comment
@xenadu000

xenadu000 Dec 3, 2017

This issue persists in Ubuntu 17.10. I found this thread while looking for a solution.

xenadu000 commented Dec 3, 2017

This issue persists in Ubuntu 17.10. I found this thread while looking for a solution.

@wdecoster

This comment has been minimized.

Show comment
Hide comment
@wdecoster

wdecoster Dec 3, 2017

Interestingly enough, this issue doesn't affect me anymore.

Ubuntu 17.10
Atom : 1.22.1
Electron: 1.6.15
Chrome : 56.0.2924.87
Node : 7.4.0

wdecoster commented Dec 3, 2017

Interestingly enough, this issue doesn't affect me anymore.

Ubuntu 17.10
Atom : 1.22.1
Electron: 1.6.15
Chrome : 56.0.2924.87
Node : 7.4.0

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot Jun 1, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

lock bot commented Jun 1, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2018

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