Skip to content
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

Improve clipboard yanking messages #2615

Closed
01mf02 opened this issue May 30, 2022 · 20 comments
Closed

Improve clipboard yanking messages #2615

01mf02 opened this issue May 30, 2022 · 20 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@01mf02
Copy link

01mf02 commented May 30, 2022

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:

  1. hx
  2. Type "Hello".
  3. Select "Hello" with the mouse.
  4. 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

@01mf02 01mf02 added the C-bug Category: This is a bug label May 30, 2022
@the-mikedavis
Copy link
Member

Does this only happen when using the mouse? Does Spacey work to copy a selection to the system clipboard?

@01mf02
Copy link
Author

01mf02 commented May 31, 2022

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 NopProvider always 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.

@the-mikedavis
Copy link
Member

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?

@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label May 31, 2022
@archseer
Copy link
Member

archseer commented Jun 1, 2022

Agreed!

@CptPotato
Copy link
Contributor

Interestingly, selecting with the mouse doesn't work on Windows while Space + y works just fine.

@sudormrfbin
Copy link
Member

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.

@DuckDuckWhale
Copy link
Contributor

DuckDuckWhale commented Jun 27, 2022

The distinction between mouse select and y isn't very clear:

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

@the-mikedavis the-mikedavis changed the title Yanking to system clipboard does not seem to do anything Improve clipboard yanking messages Jul 30, 2022
@jquesada2016
Copy link

Copying to system clipboard via space+y does not work on Windows through WSL.

@the-mikedavis
Copy link
Member

#2132

@jquesada2016
Copy link

@the-mikedavis thank you VERY much for the referral!

@amitbeka
Copy link
Contributor

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

@shaded-enmity
Copy link

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.

@ngraham20
Copy link
Contributor

ngraham20 commented Oct 14, 2022

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

@me-tantaroth
Copy link

me-tantaroth commented Oct 23, 2022

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

@kirawi kirawi added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors and removed C-bug Category: This is a bug labels Nov 10, 2022
@sayandcode
Copy link

sayandcode commented Nov 11, 2022

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)

@Ashvith10
Copy link

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.

@kirawi kirawi added the C-bug Category: This is a bug label May 11, 2023
@nexovec
Copy link

nexovec commented Oct 8, 2023

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.

@b0okle
Copy link

b0okle commented Oct 30, 2023

@nexovec Install xclip if you're on x11, or wl-clipboard if you're on wayland.

@andreaskrath
Copy link

Is this issue still relevant?

Given that there is the termcode fallback provider for clipboard that is turned on by default this should not really be an issue anymore.

Unless you consider support for custom compilations part of the scope of this issue I guess.

@the-mikedavis
Copy link
Member

Yeah we now have the OSC52 provider as a fallback and the message was adjusted slightly to say which clipboard you're yanking to in #4275. We also bubble up errors from the clipboard providers so if one fails (non-zero exit code) that should show in the UI. Configuration for clipboard provider is covered by #8826 and I think the other comments in this thread have been about debugging environments (i.e. needing to install the right clipboard tool) so I will close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
Development

No branches or pull requests