code-server: iOS copy and cut keyboard shortcuts are not working
code-server1.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
- Open and edit a file.
- Try using „cmd+c“ or „cmd+x“.
- Change the shortcuts in the settings.
- Fail again.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 16
- Comments: 98 (16 by maintainers)
Merged the latest VS Code, will be in 3.6.0 very soon. Keep an eye on the milestone to see progress.
This just got merged upstream! 😉
FYI a simple workaround I’ve used is to highlight the text, cmd+f, and then you can immediately cmd+c out of the search bar. Paste works as expected. This doesn’t solve cut, but it’s pretty usable
@rpweb The WebView didn’t seem to receive Copy Paste shortcuts, so I added a listener in the app level that then sends Copy and Paste events. It’s just Swift code, no JavaScript.
That’s the code I have in the WebView:
I don’t know what’s exactly the problem but that worked. Seems like the keyboard shortcut isn’t detected but sending the event manual works.
Edit:
copy(_:),paste(_:)andcut(_:)are methods from https://developer.apple.com/documentation/uikit/uiresponderstandardeditactions.WKWebViewimplements these methods.Well, my guess is that iOS doesn’t detect text as selected, so it doesn’t call
copy(_:)when cmd+c is pressed so calling it manually works because there is no check, we just send the function. So maybe the problem is that text is not detected as selected?As you can see in the code, I didn’t pass the iOS methods directly to the key commands, but I passed a method that called the other method. That’s because passing the methods directly didn’t work, so that would prove that iOS checks if text is selected before calling
copy(_:)when cmd+c is pressed.This probably looks like a userAgent problem?
UserAgent (Test PC)
Test Code
Not Working
Working
Result
It works!
Another workaround is installing the extension „Copy Copy Paste“ and assign Cmd+V to its paste action. It gives you an extra „hit return“ after paste, but otherwise works great at least for copy. Cut does not delete the selected text - you have to delete it on your own.
Ah. I assume we could patch that quite easily.
please use desktop mode in safari. trun on : Setting—Safari—Request dessktop website
Good news August 2020 milestone is in endgame. They are targeting next Wednesday/Thursday for release. Let’s hope code-server team can bump up vscode version quicker this time 😉
@pr1metine tried it and it was meh. Not as refined as code-server.
@rpweb Thats awesome, will definitely help us debug easier.
V3: I could reproduce the issue on MacOS when I emulate iPad in Chrome code-server via inspector!
My hopes are so high for today, Thursday.
@perelin @wei @demyxco @neoighodaro
I hope this issue will be resolved quickly. I uploaded the PR, but the vscode cannot be checked.
https://github.com/microsoft/vscode/pull/101702
iOS Copy & Cut issue.
Maybe it is iPad issue.
https://github.com/microsoft/vscode/issues/101564
https://github.com/microsoft/vscode/pull/101702
After a long trek in Azure-land – I can confirm that this is also a problem in Microsoft Visual Studio Codespaces as well. When trying that version out on Chrome on my iPad (Safari doesn’t work for some reason), copying doesn’t work. You can paste text (cmd-V) that was already in the clipboard, but you can’t paste new data. Similarly, cmd-Z doesn’t work for undo either.
Interestingly, in code-server, you can copy from the terminal; however, in VS Codespaces, you can’t copy from that terminal.
This makes me suspect that changes upstream are the primary cause for the lack of copy/paste/undo functionality in code-server as well. Given that this will be the basis for their Github codespaces product, I would wager that these problems will probably also get fixed upstream. Until then, VS App might be the best “workaround”.
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
On iOS the copy button is just greyed out. It’s like text selection doesn’t recognise that text has been highlighted in the editor view. Paste does work already if you’ve got something in the clipboard.
Seeing the same behavior. If it is a quick patch would love to see this fixed!
@kschembri Waiting for https://github.com/microsoft/vscode/wiki/Iteration-Plans Says August 2020 milestone to be released in early September. Then wait for code-server to pull it in. Currently there is an open PR in this repo to bump up vscode to its July 2020 milestone release. We’ll just have to wait maybe another 2 months 🤦 .
Awesome, then we just need to update our vs code version!
@ethanx94
Nice!! It will release august 2020
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,
You can copy from the terminal and paste into the editor. So, maybe there is hope afterall!
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:
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/
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…
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.
@schradeyannik AFAIK we do not support Safari in mobile mode, try using the Desktop mode. We have no plans to support mobile UAs due to Monaco’s limitation.
It’s been a while but I wanted you to know that I am using self-hosted server and it works well for me. I’ve just tried it /w code-server 3.3.1.
looks like copy paste work well in the app https://apps.apple.com/us/app/servediter-for-code-server/id1504491325
@nhooyr @AlfaJackal
1.48.2: https://github.com/microsoft/vscode/blob/1.48.2/src/vs/editor/browser/controller/textAreaHandler.ts#L182-L189master: https://github.com/microsoft/vscode/blob/master/src/vs/editor/browser/controller/textAreaHandler.ts#L181-L182You can tell the changes in https://github.com/microsoft/vscode/pull/101702/files are in
masterbut not1.48.2.I just installed v3.5.0. I can confirm that pasting works. However, I still cannot copy. Anyone else seeing this or is that an issue that only I am facing? 🙂
v3.5.0 with VS Code v1.48.2 has been released, fixing this issue!
Great, feedback. I just paid my AU$4.50 for iCabMobile and have dedicated it to this single purpose. Love how it can be customised. Full screen VSCode on the ipad pro works incredibly (while the macbook is in for service). Looking forward though to copy and paste running in Safari though
I was able to get copy/paste working using the iCabMobile browser, which lets you change the user agent. Definitely a hack, but its better than nothing.
microsoft/vscode/issues/101564
Looking good!
@perelin Thanks for sharing! 20 upvotes now. 👍👍
@perelin That’s not possible. Not the same workaround at least. He “fixed” it on app level. Not server level.
Yes thats a regular problem in both code-server and the app, for now i use a combination of touch scroll, shortcuts to jump between scroll pages, and the mini-map.
Ah, we removed the
v2tag but the individual v2 version tags are still there. Definitely sounds like it’s worth checking out.That’s a brilliant temporary “fix”. Thank you.
Cmd + Shift + F allows you to copy entire blocks too.
Same behaviour here. iPad Air 3, iOS 13.4
I just tried out the last V2 and it works there.
Using a V2 is the only workaround currently? (no copy/paste makes development work defacto impossible 😃
Any update on this bug? I’m having the same issue. iOS 13.3 iPad Air version 3.
Edit: So this is only in V3. Using the last build of V2 I’m having no issues with cut/copy/paste
@mattapperson This does not work either.
@sr229 @phoenixsfly The desktop mode is activated. The mentioned keyboard shortcuts do not work in desktop mode.