Skip to content

Middle-click clipboard in RStudio #1667

Open

Description

@adatum

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?

Activity

  1. kevinushey commented on Oct 25, 2017

    @kevinushey
    Collaborator

    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.

  2. self-assigned this
    on Oct 25, 2017
  3. adatum commented on Oct 25, 2017

    @adatum
    Author

    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!

  4. kevinushey commented on Oct 25, 2017

    @kevinushey
    Collaborator

    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:

    1. Enter some text into an editor in the Source pane,
    2. Press Ctrl + A to highlight the text,
    3. 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.

  5. adatum commented on Oct 28, 2017

    @adatum
    Author

    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

  6. kevinushey commented on Oct 30, 2017

    @kevinushey
    Collaborator

    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.

  7. adatum commented on Oct 30, 2017

    @adatum
    Author

    I don't use Unity. Gnome2/MATE.

  8. kevinushey commented on Oct 30, 2017

    @kevinushey
    Collaborator

    Thanks for clarifying. We'll see if we can get to the bottom of this.

  9. lwhansen commented on Apr 4, 2018

    @lwhansen

    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.

  10. kevinushey commented on Apr 4, 2018

    @kevinushey
    Collaborator

    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

  11. ClaytonJY commented on Apr 6, 2018

    @ClaytonJY

    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.

  12. 56 remaining items

  13. ronblum commented on Aug 28, 2024

    @ronblum
    Contributor

    Question: Has anyone tried this with the editor in visual mode or only source mode?

  14. jagerman commented on Aug 28, 2024

    @jagerman

    Investigating this a little further:

    • 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.

  15. ronblum commented on Aug 28, 2024

    @ronblum
    Contributor

    @jagerman Thank you for info, including the hint!

  16. kevinushey commented on Sep 4, 2024

    @kevinushey
    Collaborator

    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.

  17. added this to the Mariposa Orchid milestone on Sep 5, 2024
  18. modified the milestones: Later, Backlog on Jan 15, 2025
  19. kevinushey commented on Jan 15, 2025

    @kevinushey
    Collaborator

    This is still something I'd like to do eventually; moving to Backlog.

  20. petrelharp commented on Feb 11, 2025

    @petrelharp

    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.

  21. petrelharp commented on Feb 11, 2025

    @petrelharp

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions