microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.32k stars 8.29k forks source link

Mosh + WSL - cannot copy-and-paste #12638

Closed kellytrinh closed 2 years ago

kellytrinh commented 2 years ago

Windows Terminal version

1.11.3471.0

Windows build number

Version 10.0.19043.1526

Other Software

Ubuntu 18.04 running under WSL mosh 1.3.2 tmux 2.6

Steps to reproduce

  1. within setting.json have tab setup as "wsl.exe mosh hostname"
  2. host has tmux with mouse support via tmux.conf "set -g mouse on"
  3. open session with the host using that tab
  4. try to copy text by selecting text

Expected Behavior

Expected that the text is copied and can paste as usual from windows clipboard

Actual Behavior

The clipboaard is untouched. Previous contents still there.

Note: Isolated to some interaction between mosh when run from 'settings.json' in windows terminal.

For the same setup:

zadjii-msft commented 2 years ago

When you enable set -g mouse on in tmux, you're entering "mouse mode". That gives tmux full control over the mouse events, including clicking and dragging. So any selection you might see on the screen isn't actually a selection created by the Terminal, but rather one owned by tmux itself. If you want to escape the tmux mouse handling, you can hold shift while dragging, which will make a normal Terminal selection. That, you should be able to still copy as expected.

Does that work as expected for you?

kellytrinh commented 2 years ago

The hold-shift workaround doesn't respect vertical panes in tmux (the selection doesn't wrap around the pane borders) so is not helpful unfortunately.

I do see that tmux is capturing the mouse events. When using ssh, when I am selecting text, tmux will highlight the selection, wrapping around the vertical pane borders correctly, and upon release of mouse button the selection is copied correctly. But when switch over to mosh then it doesn't work anymore - during the hold-mouse-button phase tmux is highlighting the selection as before; but upon releasing mouse button - the selection isn't copied to clipboard.

Perhaps issue is something around how Windows Terminal is passing the mouse-button-release event to ssh vs mosh?

zadjii-msft commented 2 years ago

Hey sorry, haven't had the chance to dig in too much further. The triage queue is deep, sorry this got lost. My theory is that this has to do with OSC52, "MANIPULATE SELECTION DATA", or "copy to clipboard". (see implementation in #5823).

I wonder if mosh is eating the OSC52's. That would prevent the Terminal from ever being told what the new clipboard contents should be.

zadjii-msft commented 2 years ago

https://andrewmzhang.com/blog/2020/osc-52-patch-for-vte-0425/ https://gist.github.com/yudai/95b20e3da66df1b066531997f982b57b https://github.com/mobile-shell/mosh/pull/1054

Yea this might be a mosh issue. Can you try changing your tmux conf like in the above posts, to see if that remedies this/?

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.