fix: resolve Windows clipboard (Ctrl+V/X/C) not working in WebView2#517
Merged
Conversation
Three root causes prevented clipboard operations on Windows:
1. Native Tauri menu registered keyboard accelerators for cut/copy/paste
that intercepted keystrokes before reaching the WebView, and its
paste handler called execCommand('paste') which WebView2 blocks
for security → made menu macOS-only.
2. platform.isNative is false in Tauri, so PasteAction/CutAction/CopyAction
had no Ctrl+V/X/C keybinding registered → added platform.isTauri
to the kbOpts condition for all three actions.
3. SendInput-synthesized Ctrl+V was re-caught by PasteAction (re-entrancy)
and triggerPaste via external process was fragile → disabled
triggerPaste and use direct clipboard read + editor.trigger() for the
editor, and synthetic ClipboardEvent dispatch for non-editor contexts
(terminal, etc.).
Also replaced PowerShell SendKeys with Win32 SendInput API and
simplified clipboard helper methods.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CI failed because cargo fmt --check found formatting issues. Ran cargo fmt to auto-format the code. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Clippy warned that `map_or(false, |t| !t.is_empty())` can be simplified to `is_ok_and(|t| !t.is_empty())`. Resolves CI Backend Lint (Clippy) failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
platform.isTaurito clipboard keybinding registration for Cut/Copy/Paste actionsChanges
Root causes fixed
.paste(),.cut(),.copy()) registered keyboard accelerators that intercepted Ctrl+V/X/C before reaching the WebView. The paste handler calledexecCommand('paste')which WebView2 blocks for security.platform.isNativeisfalsein Tauri, so PasteAction/CutAction/CopyAction had no Ctrl+V/X/C keybindings registered.editor.trigger()for the editor and syntheticClipboardEvent('paste')dispatch for non-editor contexts (terminal, etc.).Files changed
src-tauri/src/commands/native_host/clipboard.rs— Replace PowerShell SendKeys with Win32 SendInput API, simplify helper methodssrc-tauri/src/window/menu.rs— Make native menu setup macOS-only via#[cfg(target_os = "macos")]src/vs/editor/contrib/clipboard/browser/clipboard.ts— Addplatform.isTaurito kbOpts for Cut/Copy/Paste, add Tauri-specific paste paths (direct clipboard read for editor, synthetic paste event for terminal)src/vs/workbench/services/clipboard/tauri-browser/clipboardService.ts— DisabletriggerPaste()(returnundefined) to use direct clipboard read path insteadTest plan
🤖 Generated with Claude Code