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

iOS copy and cut keyboard shortcuts are not working

Open schradeyannik opened this issue 7 years ago • 98 comments

  • code-server 1.1156-vsc1.33.1
  • OS Version: iPadOS 13.1 Beta 4 (on iPad Pro 2018 12.9)

Description

The keyboard shortcuts for copying and cutting text don‘t work. Changing the shortcuts in the code-server settings to something different of „cmd+c“ and „cmd+x“ does not help.

Steps to Reproduce

  1. Open and edit a file.
  2. Try using „cmd+c“ or „cmd+x“.
  3. Change the shortcuts in the settings.
  4. Fail again.

schradeyannik avatar Sep 20 '19 20:09 schradeyannik

Glad to see this is an open issue, why was the clipboard API removed in v3 for editors? V2 works flawlessly on my iPad Pro.

demyxco avatar Apr 27 '20 19:04 demyxco

Hmm, maybe we should double-check v2. I don't believe we made any changes but it's possible VS Code did. To confirm, cmd+c, cmd+x, and cmd+v work when editing a file in v2 but not in v3?

code-asher avatar Apr 27 '20 19:04 code-asher

To confirm, cmd+c, cmd+x, and cmd+v work when editing a file in v2 but not in v3?

Correct. Though in v3, paste gets disabled when switching tabs. It’s probably due to it losing focus from the attempting to reconnect dialog? You have to click the terminal first then the editor to paste again.

demyxco avatar Apr 27 '20 19:04 demyxco

Point is, in some places it does work! If you right click on a file and select “copy path” it works. So, to me it looks like it’s only in the code focus where you cannot copy.

Btw, did any of you managed to use the virtual keyboard in the code view? I don’t get it open, maybe it’s linked to this issue here, might be it’s a focus stuff.

Mrc527 avatar Apr 28 '20 15:04 Mrc527

V3: I guess its also related to the Keyboard layout. MacOS (chrome) works with cmd Bildschirmfoto 2020-04-28 um 20 50 32

iPad (chrome) with new apple keyboard detects linux layout (MOBILE version) and works with control instead of cmd. control + c + x doesn't work, but control + shift + z + a + v etc. works. PNG-Bild

DESKTOP version on iPad (chrome) detects same keyboard as on MacOS (cmd works), but only with + shift + z + a + v. Combination with cmd + c + x don't work. (same as on MOBILE version) PNG-Bild 2

Fun fact: When I copy text on MacOS I can paste it immediately on my iPad. Somehow scary as well.

I will do further testing.

rpweb avatar Apr 28 '20 19:04 rpweb

V3: I could reproduce the issue on MacOS when I emulate iPad in Chrome code-server via inspector! Bildschirmfoto 2020-04-28 um 21 27 07

rpweb avatar Apr 28 '20 19:04 rpweb

@rpweb Thats awesome, will definitely help us debug easier.

nhooyr avatar Apr 30 '20 06:04 nhooyr

I've been fighting with this for the better part of a week, and I think I understand what is happening. Strangely, what I've seen is that I can paste anything, but I can't copy anything new into the clipboard. If the clipboard already has the information I want, then it can be read with cmd-V, as expected.

I loaded my iPad up in the Safari remote debugger (by plugging the iPad into my computer via usb-c), and was looking for some error messages. I didn't see anything when I tried to use cmd-C. So, I tried programmatically copy/pasting.

What I saw was this:

Screen Shot 2020-05-05 at 1 27 58 PM

This led me to start looking for granting permissions to the clipboard in Safari. And unfortunately, I don't think it will be possible. From my reading, I think that the only way for web applications to interact with the clipboard is using the system copy/paste UI. This is a recent update to the iPadOS/Safari code. And this obviously won't work with an editor like code-server/VSCode that is expecting to be able to use keyboard shortcuts.

Here's the update from Webkit that mentions this behavior: https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/

The implementation is available through the navigator.clipboard API which must be called within user gesture event handlers like pointerdown or pointerup, and only works for content served in a secure context (e.g. https://). Instead of a permissions-based model for reading from the clipboard, a native UI is displayed when the page calls into the clipboard API; the clipboard can only be accessed if the user then explicitly interacts with the platform UI.

So, the issue maybe a combination of code-server and the version of iPadOS in use. I'm not sure if there is a work around...

mbreese avatar May 05 '20 17:05 mbreese

I've been fighting with this for the better part of a week, and I think I understand what is happening. Strangely, what I've seen is that I can paste anything, but I can't copy anything new into the clipboard. If the clipboard already has the information I want, then it can be read with cmd-V, as expected.

I loaded my iPad up in the Safari remote debugger (by plugging the iPad into my computer via usb-c), and was looking for some error messages. I didn't see anything when I tried to use cmd-C. So, I tried programmatically copy/pasting.

What I saw was this:

Screen Shot 2020-05-05 at 1 27 58 PM

This led me to start looking for granting permissions to the clipboard in Safari. And unfortunately, I don't think it will be possible. From my reading, I think that the only way for web applications to interact with the clipboard is using the system copy/paste UI. This is a recent update to the iPadOS/Safari code. And this obviously won't work with an editor like code-server/VSCode that is expecting to be able to use keyboard shortcuts.

Here's the update from Webkit that mentions this behavior: https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/

The implementation is available through the navigator.clipboard API which must be called within user gesture event handlers like pointerdown or pointerup, and only works for content served in a secure context (e.g. https://). Instead of a permissions-based model for reading from the clipboard, a native UI is displayed when the page calls into the clipboard API; the clipboard can only be accessed if the user then explicitly interacts with the platform UI.

So, the issue maybe a combination of code-server and the version of iPadOS in use. I'm not sure if there is a work around...

Hi @mbreese thanks for your feedback, I really appreciate it. I have a question: why is it possible to copy for instance the path of a file? image This one works for me on my iPad, updated with the latest iPad OS.

Is this in contradiction with your conclusions? Might be this is not, since this button is acting on an element that is outside of the editor view or maybe because this is not using a keyboard shortcut...

Mrc527 avatar May 05 '20 17:05 Mrc527

Hi @mbreese thanks for your feedback, I really appreciate it. I have a question: why is it possible to copy for instance the path of a file? image This one works for me on my iPad, updated with the latest iPad OS.

Is this in contradiction with your conclusions? Might be this is not, since this button is acting on an element that is outside of the editor view or maybe because this is not using a keyboard shortcut...

Yes, that works. But I think the difference is where the source of the clipboard text is. Even above, I mentioned that I could still paste w/ cmd-V, but only something that was clipped from a different app (like notes, email, or the safari url, etc).

So, what we've shown is that you can a) programmatically add data to the clipboard and b) programmatically paste data from the clipboard

What you can't do is copy user-data to the clipboard. So, my guess is that it's somewhere in the selection API. If you run (from the console):

window.getSelection().toString()

On Safari on my Mac, I get the correct selected text. On my iPad, I get an empty string (""). I think this is where the root issue lies.

You're right that this all seems strange and contradictory. It also seems like it doesn't match the Webkit announcement at all. The rest of it may end up a red herring. I believe that any copy/paste code needs to run in the context of a user event (keydown, pointerdown, etc). The tests I've been doing haven't done that, so maybe that's another issue with the testing?

And strangely, undo/redo also works. I expect that's a similar mechanism as copy/paste. As does dragging and dropping... (select code, drag it around to move it someplace else).

Finally to add to the confusion... from @code-asher above,

For the terminal it uses the clipboard API if it can but for the editor I don't think it does. I think it just uses native paste there.

You can copy from the terminal and paste into the editor. So, maybe there is hope afterall!

mbreese avatar May 05 '20 19:05 mbreese

I working with the v2 docker container and copy/paste with CMD-C works. (Strangely the codercom/code-server:v2 tag doesn`t exist anymore on docker hub...) Could it help to analyze what changed between v2 and v3?

perelin avatar May 12 '20 16:05 perelin

Ah, we removed the v2 tag but the individual v2 version tags are still there. Definitely sounds like it's worth checking out.

code-asher avatar May 12 '20 17:05 code-asher

I´d love to do it, but I´m afraid I don´t have the necessary expertise :(

perelin avatar May 14 '20 08:05 perelin

Glad I found this, i thought I may have installed something that caused this behavior. I would absolutely love to see it work. If it did (and still works, maybe someone can confirm this) work in v2, then likely more a code change and less but still possibly an iPadOS issue.

neoighodaro avatar May 16 '20 10:05 neoighodaro

Can confirm again: works in codercom/code-server:v2 but I haven´t tried any of the other v2 tags

perelin avatar May 18 '20 08:05 perelin

Can confirm this is an issue. Tried remapping the copy / paste shortcuts and now I get the error: Command ‘references-view.copy’ not found.

kschembri avatar May 18 '20 16:05 kschembri

For those using an iPad, you can temporarily use this app called VS App - code server, they pushed an update to the app that fixes copy/paste.

You can use your custom code server in the app itself and not have to pay

neoighodaro avatar May 20 '20 09:05 neoighodaro

For those using an iPad, you can temporarily use this app called VS App - code server, they pushed an update to the app that fixes copy/paste.

You can use your custom code server in the app itself and not have to pay

Nice to hear, but what exactly is the fix? Can't we implement it into code-server?

rpweb avatar May 20 '20 09:05 rpweb

For those using an iPad, you can temporarily use this app called VS App - code server, they pushed an update to the app that fixes copy/paste. You can use your custom code server in the app itself and not have to pay

Nice to hear, but what exactly is the fix? Can't we implement into code-server?

No idea, it's closed source i believe. Just found out that they pushed the update for this fix and i decided to try if it works with my custom code-server and it did.

neoighodaro avatar May 20 '20 09:05 neoighodaro

@neoighodaro nice find! I think the app itself is doing the copy/cut instead of the browser? Also it has the ability to upload folders/files; which is a nice touch. I seen this app a while ago but assumed it was for the app developer’s platform.

demyxco avatar May 20 '20 09:05 demyxco