You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a linux user, I like highlighting text to copy, and middle-clicking to paste, as it is fast. I often wish to do this between the editor and console in RStudio, but it does not work. Is there any possibility of fixing this in the future?
Reacted by Tung N, Clayton Yochum, wc18, Adriano Fantini, Matej, Alexey Sergushichev and Cedric R.
This seems like an unfortunate omission on our part -- we did some work to enable middle-click pasting in v1.1, and this does work (RStudio -> other application), but unfortunately middle-click pasting doesn't seem to work in RStudio editors.
Playing around a little bit more, it seems like there is something a bit trickier going on -- it seems like it works half the time, and doesn't work the other half of the time. The following consistently works for me:
Enter some text into an editor in the Source pane,
Press Ctrl + A to highlight the text,
Middle-click somewhere on the console.
Those middle-clicks seem to succeed consistently. (I did learn that one does need to middle-click quickly -- if you press the middle button down, hold it for a second, and then release, the middle-click paste does not occur. This appears to be a universal behavior; not specific to RStudio.)
However, the same action from Console -> Source editor does not work until the second click. The first click focuses the editor but loses the paste; the second click successfully pastes.
Sometimes highlight/middle-click works perfectly between external applications/Console/Editor, other times it doesn't work at all or just in certain directions.
Sometimes it pastes directly where the mouse pointer was when it was middle-clicked (expected behavior), other times it pastes where there is an existing cursor blinking (independent of the mouse pointer) in the editor.
I haven't found a pattern yet.
System info:
RStudio 1.1.383
R version 3.4.2 (2017-09-28)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu 16.04.3 LTS
For what it's worth, the behavior seems a lot more consistent (at least for me) running with Ubuntu 17.10 (as that now uses Gnome 3); it's possible that we're running afoul of some Unity-specific misbehaviors here.
Just want to reiterate, that this is still not working with latest version (1.1.383). I consistently get the old selection on first middle click and the new on second click. This is within a notebook window, running latest Kubuntu. Quite frustrating.
Everything works fine for me with a freshly-installed Kubuntu 16.04 VM + RStudio v1.1.442. Are you running any other desktop applications that might make use of or monitor the selection clipboard? Maybe that and RStudio are competing for access and this is causing issues of some form?
As an extra data point, I'm also using RStudio v1.1.383, but on Linux Mint v18.3 (based on Ubuntu 16.04) w/ KDE 5, and middle-clicking works both to and from RStudio.
I don't know if this could be it, but @lwhansen are you on an older KDE version? kf5-config --version says I'm on KDE 5.36.
if I select something in another window and then middle click into the RStudio source editor without letting the RStudio window have focus first then it will successfully paste exactly once.
if I do the same into the Console, then it sometimes works on the first try, sometimes on the second try, and sometimes doesn't work at all.
if I select, then left-click on the editor part of the window to bring RStudio into focus, then middle click it doesn't paste.
if I select, then left-click on the title bar to bring it into focus, then middle click into the editor, it works exactly once.
But I think the real issue is this: any operations in the editor and Console -- typing, or even just moving the cursor by left-clicking or using arrow keys -- clears the global selection buffer (i.e. the selected text in the other application gets cleared). Middle-click pasting included -- which is why in even the success cases above, it only works once. This should not be happening: the global selection buffer should only be updated if I actually select something (or clear a selection), and I suspect if this was fixed, all the other issues would disappear.
For reference; we did a fair amount of work to get middle-click pasting to work with the older Qt builds of RStudio on Linux; our hope was that middle-click pasting would "just work" out-of-the-box after switching to Electron. We might still need to add some glue code to get middle-click pasting hooked up.
Some more observations (on current Debian Sid; Rstudio 2024.12.0 Build 467):
this applies to both console and editor
the cursor has two states: (1) grey and not flashing, and (2) black and flashing
middle-click-paste only seems to work when the window (either console or editor) has not just been in focus; when moving between windows within Rstudio, this is indicated by a grey cursor - so at first I thought it only works when the cursor is in state (1) - but as noted by others above, pasting into Rstudio from another application works (but only once) when the cursor is in state (2)
After middle-click pasting into Rstudio, the middle-click-paste buffer has some weird content in it: middle-click-pasting to the terminal makes the bell sound.
However, just clicking to focus in some window (which makes middle-click-paste not work in Rstudio) does not clear the buffer: I can select something in Rstudio, left-click to focus a different window, and then middle-click-paste the content elsewhere.
If I middle-click somewhere in the editor that's not where the cursor currently is that is not the end of a line (and am in a state it would normally paste), then it moves the cursor but does not paste. Doing this does clear the clipboard.
To be clear about this being a serious bug: suppose I've got text in a terminal that I want to paste into Rstudio's editor. I can't use Ctrl-C because it's the terminal (eg, bash). As noted above, this will only work if the cursor is already where I want the text to go; otherwise it moves the cursor and loses what's in the clipboard. (with some caveats about the end of the line above; sometimes this works and sometimes it doesn't)
Note some of this differs from what's reported above.
Activity
kevinushey commentedon Oct 25, 2017
This seems like an unfortunate omission on our part -- we did some work to enable middle-click pasting in v1.1, and this does work (RStudio -> other application), but unfortunately middle-click pasting doesn't seem to work in RStudio editors.
adatum commentedon Oct 25, 2017
You're right, middle-click pasting works from RStudio to other applications, but not within RStudio, or from other applications to RStudio.
If you can get this working it will be hugely appreciated and streamline the workflow in RStudio!
kevinushey commentedon Oct 25, 2017
Playing around a little bit more, it seems like there is something a bit trickier going on -- it seems like it works half the time, and doesn't work the other half of the time. The following consistently works for me:
Those middle-clicks seem to succeed consistently. (I did learn that one does need to middle-click quickly -- if you press the middle button down, hold it for a second, and then release, the middle-click paste does not occur. This appears to be a universal behavior; not specific to RStudio.)
However, the same action from Console -> Source editor does not work until the second click. The first click focuses the editor but loses the paste; the second click successfully pastes.
adatum commentedon Oct 28, 2017
Not sure, but maybe it's a focus issue.
Sometimes highlight/middle-click works perfectly between external applications/Console/Editor, other times it doesn't work at all or just in certain directions.
Sometimes it pastes directly where the mouse pointer was when it was middle-clicked (expected behavior), other times it pastes where there is an existing cursor blinking (independent of the mouse pointer) in the editor.
I haven't found a pattern yet.
System info:
RStudio 1.1.383
R version 3.4.2 (2017-09-28)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu 16.04.3 LTS
kevinushey commentedon Oct 30, 2017
For what it's worth, the behavior seems a lot more consistent (at least for me) running with Ubuntu 17.10 (as that now uses Gnome 3); it's possible that we're running afoul of some Unity-specific misbehaviors here.
adatum commentedon Oct 30, 2017
I don't use Unity. Gnome2/MATE.
kevinushey commentedon Oct 30, 2017
Thanks for clarifying. We'll see if we can get to the bottom of this.
lwhansen commentedon Apr 4, 2018
Just want to reiterate, that this is still not working with latest version (1.1.383). I consistently get the old selection on first middle click and the new on second click. This is within a notebook window, running latest Kubuntu. Quite frustrating.
kevinushey commentedon Apr 4, 2018
Everything works fine for me with a freshly-installed Kubuntu 16.04 VM + RStudio v1.1.442. Are you running any other desktop applications that might make use of or monitor the selection clipboard? Maybe that and RStudio are competing for access and this is causing issues of some form?
It would also be worth trying the latest daily builds of RStudio, to see if the situation is at all improved there for you: https://dailies.rstudio.com
ClaytonJY commentedon Apr 6, 2018
As an extra data point, I'm also using RStudio v1.1.383, but on Linux Mint v18.3 (based on Ubuntu 16.04) w/ KDE 5, and middle-clicking works both to and from RStudio.
I don't know if this could be it, but @lwhansen are you on an older KDE version?
kf5-config --versionsays I'm on KDE 5.36.56 remaining items
ronblum commentedon Aug 28, 2024
Question: Has anyone tried this with the editor in visual mode or only source mode?
jagerman commentedon Aug 28, 2024
Investigating this a little further:
But I think the real issue is this: any operations in the editor and Console -- typing, or even just moving the cursor by left-clicking or using arrow keys -- clears the global selection buffer (i.e. the selected text in the other application gets cleared). Middle-click pasting included -- which is why in even the success cases above, it only works once. This should not be happening: the global selection buffer should only be updated if I actually select something (or clear a selection), and I suspect if this was fixed, all the other issues would disappear.
ronblum commentedon Aug 28, 2024
@jagerman Thank you for info, including the hint!
kevinushey commentedon Sep 4, 2024
For reference; we did a fair amount of work to get middle-click pasting to work with the older Qt builds of RStudio on Linux; our hope was that middle-click pasting would "just work" out-of-the-box after switching to Electron. We might still need to add some glue code to get middle-click pasting hooked up.
kevinushey commentedon Jan 15, 2025
This is still something I'd like to do eventually; moving to Backlog.
petrelharp commentedon Feb 11, 2025
Some more observations (on current Debian Sid; Rstudio 2024.12.0 Build 467):
To be clear about this being a serious bug: suppose I've got text in a terminal that I want to paste into Rstudio's editor. I can't use Ctrl-C because it's the terminal (eg, bash). As noted above, this will only work if the cursor is already where I want the text to go; otherwise it moves the cursor and loses what's in the clipboard. (with some caveats about the end of the line above; sometimes this works and sometimes it doesn't)
Note some of this differs from what's reported above.
petrelharp commentedon Feb 11, 2025
Context: I'm teaching a bunch of data science students about R who are used to using jupyter+python; it'd be nice if Rstudio didn't look hackey.
harden linux middle-click primary-selection paste (#18078)