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

Fix system clipboard with mosh + tmux #9834

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

useche
Copy link
Contributor

@useche useche commented Mar 8, 2024

Some times tmux doesn't pass the clipboard information to the terminal correctly. One example of this is mosh + tmux. In this case the current clipboard doesn't work properly. However, when the tmux option allow-passthrough is on, we can escape tmux and pass the OSC52 string directly to the terminal.

In this patch, if helix detects that tmux allow-passthrough is on, it will use the OSC52 clipboard provider and will escape tmux and pass the OSC52 directly to the terminal.

Tested with mosh + tmux with the allow-passthrough option on.

@the-mikedavis the-mikedavis added the S-waiting-on-review Status: Awaiting review from a maintainer. label Mar 8, 2024
@useche useche changed the title Add clipboard support for tmux allow-passthrough Fix system clipboard with mosh + tmux Mar 8, 2024
@atahrijouti
Copy link
Contributor

Doesn't this code make helix coupled to tmux specifically and only fix tmux rather than the special issue of any wrapper app not passing clipboard through?
Couldn't this be implemented in such a way that enables OSC52 if it is wanted instead?

@useche
Copy link
Contributor Author

useche commented Mar 31, 2024

Doesn't this code make helix coupled to tmux specifically and only fix tmux rather than the special issue of any wrapper app not passing clipboard through?

Hi! This patch makes Helix as coupled to tmux as it has been in the past (helix already checks if it's currently inside tmux to make decisions about how to setup the clipboard). The only difference is that apart from checking if it is inside tmux, it also checks if some particular feature of tmux is enabled to use it.

Couldn't this be implemented in such a way that enables OSC52 if it is wanted instead?

I'm not sure what you mean here. Helix already has OSC52 support as fallback mechanism is no other was found suitable. From the question it sounds like you were looking to add an option to the config file to force OSC52? I thought about this one too, but I've seen reluctance in adding new options to Helix config and realized that the decision could be automated this way.

@atahrijouti
Copy link
Contributor

@useche Yes that's what I meant about enabling when wanted, ans thank you for the explanations I didn't know about the existing checks targeting tmux 👍

Comment on lines 172 to 175
} else if tmux_allow_passthrough() {
// If we are in tmux and it allows passthrough, lets use OSC52 and escape tmux.
Box::new(provider::FallbackProvider::new())
} else if env_var_is_set("TMUX") && binary_exists("tmux") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a separate branch rather than nesting under the next one that's already checking for tmux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why I did that. I combined the the two branches.

Comment on lines +103 to +105
if !env_var_is_set("TMUX") {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this check would be redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need this check. The reason is that this function is also used in the OSC52 fallback, which won't necessarily be used with tmux. So, to escape OSC52 string through tmux, we still need to check if we are in tmux and whether the feature is on or not.

@useche useche force-pushed the osc52_tmux_passthrough branch 3 times, most recently from 190202e to 6a9b791 Compare April 2, 2024 20:32
@useche
Copy link
Contributor Author

useche commented Apr 2, 2024

I added documentation for a better explanation of the feature and how to enable it.

Some times tmux doesn't pass the clipboard information to the terminal
correctly. This is the case of mosh + tmux. The current clipboard
doesn't work properly in this case. However, when the tmux option
`allow-passthrough` is on, we can escape tmux and pass the OSC52 string
directly to the terminal.

In this patch, if helix detects that tmux `allow-passthrough` is on, it
will use the OSC52 clipboard provider and will escape tmux and pass the
OSC52 directly to the terminal.

Tested with mosh + tmux with the `allow-passthrough` option on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants