helix
helix copied to clipboard
Improve clipboard yanking messages
Summary
When selecting some text with the mouse, the message "yanked main selection to system clipboard" appears at the bottom, yet the clipboard does not seem to contain the selected text.
Reproduction Steps
I tried this:
hx- Type "Hello".
- Select "Hello" with the mouse.
- Open a GTK application such as Mousepad or Firefox, and paste with middle mouse button or CTRL-V (tried both).
I expected this to happen:
The text "Hello" should appear in the GTK application.
Instead, this happened:
Some previously selected text appears in the GTK application.
Helix log
Nothing interesting here.
Platform
Linux
Terminal Emulator
xfce4-terminal 0.8.10
Helix Version
22.05-10-g370a16d0
Does this only happen when using the mouse? Does Spacey work to copy a selection to the system clipboard?
This happens both with mouse and Space y.
I found the culprit in the meanwhile: In helix-view/src/clipboard.rs, Helix checks for the existence of several tools, such as xsel and xclip to use for clipboard operations. If none of these tools is available, then a NopProvider is used which provides a Helix-specific clipboard, but this can be hardly called a "system clipboard".
Therefore, I find the message "yanked main selection to system clipboard" misleading.
After installing xclip, yanking works as expected.
I see several ways to improve the current situation:
- The error message in helix-term/src/commands.rs could be triggered when no clipboard tool is found. One way to achieve this would be to make the
NopProvideralways fail instead of always succeed. - The message "yanked main selection to system clipboard" could be changed to something like "yanked main selection to Helix clipboard (install a clipboard tool to use system clipboard)" when no clipboard tool is found.
Yeah improving that error message would be great. I think I would prefer that the system clipboard commands fail when the contents can't be copied so it's more noticeable. What do others think?
Agreed!
Interestingly, selecting with the mouse doesn't work on Windows while Space + y works just fine.
Selecting with the mouse copies text to the secondary clipboard in Linux, which doesn't exist in Windows. We could copy to the clipboard for windows in this case, but that would probably be too disruptive - the secondary clipboard in Linux doesn't override the contents of a normal ctrl+c made in some other application, while in Windows (due to a lack of multiple clipboards) it will.
The distinction between mouse select and
- Mouse:
yanked main selection to system clipboard - Space + y:
joined and yanked 1 selection(s) to system clipboard
It is not clear from this prompt that one of them goes to the middle click clipboard yet the other one goes to the normal (Ctrl+C/V) clipboard. Does anyone know what's the correct term for not only X (which I know are clipboard and primary) but also Wayland? (Maybe we just call them "system clipboard" and "system selection clipboard"? Also, the joined and yanked 1 selections(s) is unnecessary. Simply yanked selection to system clipboard would do.
Copying to system clipboard via space+y does not work on Windows through WSL.
https://github.com/helix-editor/helix/issues/2132
@the-mikedavis thank you VERY much for the referral!
cross-posting here:
I've started working on this, learning Rust as I go 😅 Adding this to the healthcheck now, then I'll look into the error message in-app: #3271
I'm using helix 22.08.1 (66276ce6) on mac + iterm2, when I select text with mouse it says yanked main selection to system clipboard but the actual text is not in the clipboard/any register. Using space + Y prints the same message but actually works as expected.
Running on RHEL 8 here, and space + y yanks to system clipboard, but the mouse select does not. hx --health shows using xclip.
I've just looked at other issues, and now realize that the mouse selection clipboard is the middle-mouse click clipboard, while space + y is the ctrl+c/v clipboard. Also, I now see someone else said the same thing further up facepalm
Hi i am trying to use space + Y to be able to copy text from helix to main clipboard but it doesn't, try to paste the text outside helix but it doesn't work. I have xclip installed on a Chrome OS with debian 11 VM
$ hx --health
Config file: default Language file: default Log file: /home/myuser/.cache/helix/helix.log Runtime directory: /home/myuser/.config/helix/runtime Clipboard provider: xclip System clipboard provider: xclip
Faced the same problem. I had no idea why copy paste to system clipboard wasn't working, when it clearly showed a success message. I thought it was just a helix bug. Technically it is tho. Thanks to @01mf02 for providing a workaround with xclip. (I'm running ubuntu)
Okay, this is something I've encountered as well, and it works after install xclip. I've also tried this with wl-clipboard, and it works fine.
When I select the entire document with % and then try to yank to system clipboard, helix freezes. When I select a line with x and then try to yank to system clipboard, nothing gets yanked.
@nexovec Install xclip if you're on x11, or wl-clipboard if you're on wayland.