paste: Listen to the clipboard event instead of using the browser clipboard API
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
When using VSCode through a browser page (ala https://github.com/coder/code-server), pasting works as intended. However, if the Vim extension is enabled, paste errors with:
Unable to read from the browser's clipboard. Please make sure you have granted access for this website to read from the clipboard.
From https://github.com/microsoft/vscode/issues/164769:
[...] the vim extension binds ctrl+v as a keybinding and then resorts to use vscode clipboard reading APIs which are ultimately implemented with the browser clipboard reading APIs.
[...] the builtin editor does not rely on adding a keybinding for ctrl+v and then using browser APIs to read the clipboard. The builtin editor listens to the paste event. Browsers give the paste data in the paste event even if consent was not obtained because in that case the browser can prove itself that the user generate the paste.
From the VSCode source: https://github.com/microsoft/vscode/blob/79c704721abdeefbcef6a1576a770b4d713bbff6/src/vs/editor/contrib/clipboard/browser/clipboard.ts#L124
// Do not bind paste keybindings in the browser, // since browsers do that for us and it avoids security prompts
VSCode seems to listen on ClipBoard events. Would it be possible for the extension to also do the same, so that pasting works regardless of whether the website has sufficient permissions?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the linked VS Code clipboard source first, especially its browser paste handling, then inspect the extension's paste and keybinding handling. Done means pasting works in browser-hosted VS Code without requiring browser clipboard-read permission, while existing paste behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100