code-server icon indicating copy to clipboard operation
code-server copied to clipboard

Copy and Cut to Clipboard not working in Safari or App Containers like Unite/Fluid

Open TomFrost opened this issue 7 years ago • 13 comments

  • code-server version: 1.939-vsc1.33.1
  • OS Version: Ubuntu 18.04 LTS
  • Safari Version: 12.1 on macOS Mojave

Description

When using Safari or any application container that uses Safari as the engine (such as those generated by Unite or Fluidapp -- my favorite way to use code-server), highlighting text and pressing Cmd+C, Cmd+X, or choosing "Copy" or "Cut" from the Edit menu has no effect. Pasting after doing any of those things results in the previous contents of the clipboard being pasted. Chrome does not have this issue.

Steps to Reproduce

  1. Copy text to your clipboard from any text file or website outside of code-server
  2. Open code-server in Safari and highlight text in an open file
  3. Press Cmd+C
  4. Press Cmd+V. The text copied in Step 1 will be pasted.

Thanks for this incredible project!

TomFrost avatar Apr 23 '19 04:04 TomFrost

Playing around with different releases, this commit last night seems to be the culprit: https://github.com/codercom/code-server/commit/2bc6e1a457b4ca5298f5207d164a3699ec443bfc

TomFrost avatar Apr 23 '19 13:04 TomFrost

Any update on a release date for this fix?

BaileyJM02 avatar May 17 '19 18:05 BaileyJM02

I'm also running into this and it's pretty annoying.

niemyjski avatar May 20 '19 14:05 niemyjski

I managed to downgrade with out any problems - just use the same settings and execute the older build file. It’s not broken on the version below :)

I haven’t updated to the newer version yet as i’m sure this bug still exists.

BaileyJM02 avatar May 20 '19 15:05 BaileyJM02

Any workarounds for this in the short-term?

drewcovi avatar Jun 10 '19 20:06 drewcovi

Long-term is downgrade to the version prior to this commit: https://github.com/cdr/code-server/commit/2bc6e1a457b4ca5298f5207d164a3699ec443bfc I mean you can always use another browser but I haven’t seen anything related to this within any commits yet.

BaileyJM02 avatar Jun 10 '19 20:06 BaileyJM02

So it's the copying that doesn't work while the paste works fine?

We try to use the clipboard API if navigator.clipboard exists (we call navigator.clipboard.writeText()). If permission has been denied it will fail silently (we need to add an error popup message for this).

If navigator.clipboard doesn't exist it inserts the text to copy into an input then runs execCommand("copy"). We should show a message when that fails, too.

code-asher avatar Jun 10 '19 22:06 code-asher

Additionally, if permission has been denied we should fall back to the execCommand method (for both copy and paste).

code-asher avatar Jun 10 '19 22:06 code-asher

Yeah i didn’t have a lot of time to dig that deep, but suffice to say, regardless of what’s supported, the current implementation results in a broken copy (as in I can’t even copy out of the editor to a notepad)

drewcovi avatar Jun 10 '19 22:06 drewcovi

@code-asher I also get some errors such as: image when using the last version before copy and paste was broken.

Any update on progress? Really wanna update to see if it fixes the memory hog issue.

BaileyJM02 avatar Jun 21 '19 13:06 BaileyJM02

I have the save issue on IpadOS 13. With version 1.1156-vsc1.33.1. Can not copy or cut anything.

NGarate avatar Jul 06 '19 17:07 NGarate

Just for iPadOS, I wanted to share a hack I've been using locally to achieve full clipboard functionality (please see the commit linked above).

Maybe it will be useful to anyone similarly desperate to access code-server on an iPad, but unfortunately in its current form it isn't pull-request appropriate. It's the best I could manage via editing the patch file by hand.

admvx avatar Jul 12 '19 06:07 admvx

The copy/paste mechanism in question has been entirely replaced with v2 so I'm going to close this. The only clipboard issues I'm aware of now are #1106 and #1015.

code-asher avatar Oct 24 '19 22:10 code-asher