Skip to content

[VS Code Shell] Fix CTRL/CMD + C Copy#2714

Merged
GeorgeNgMsft merged 7 commits into
mainfrom
dev/georgeng/vscode_copy
Jul 21, 2026
Merged

[VS Code Shell] Fix CTRL/CMD + C Copy#2714
GeorgeNgMsft merged 7 commits into
mainfrom
dev/georgeng/vscode_copy

Conversation

@GeorgeNgMsft

@GeorgeNgMsft GeorgeNgMsft commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fix copy/paste in the VS Code shell chat

Text in the TypeAgent VS Code chat couldn't be copied with the keyboard, and the message input was awkward to select. This fixes both. Changes live in the shared  chat-ui  package (wired up from the VS Code webview); the Electron shell is unaffected.

image

What changed

Keyboard copy / cut works everywhere in the chat

• Problem: In the VS Code chat,  Ctrl/Cmd+C  (and  Ctrl/Cmd+X ) did nothing on selected text — only the right-click menu copied. VS Code webviews don't run the native clipboard action on a DOM selection; only the JS clipboard path works.
• Fix: Added  handleClipboardShortcut  in  chat-ui  (reusing the same  navigator.clipboard  path the right-click menu already uses) and wired it from a keydown listener in the VS Code webview. Copy now works across the chat history and the message input; cut works in editable fields. Covers plain text selections and native   / <textarea>  selections.
• Electron keeps its native clipboard keys, so it's left untouched.

Message input is fully drag-selectable

• Problem: The input is a  display: inline  contentEditable span, so its box is wider than the text. Starting a drag anywhere except directly on the text landed on the padding and selected nothing.
• Fix: Rewrote the input's press handling to use pointer capture with geometry-clamped caret mapping, so you can start a selection anywhere in the input box (up to the buttons) and drag to select — with clean anchor/extend behavior.

GeorgeNgMsft and others added 6 commits July 20, 2026 17:34
The message input is a display:inline contentEditable span, so its flex
wrapper is wider than the text run. A press in that empty padding landed
on the wrapper (not the editable), so a selection couldn't begin there -
you could only select by starting the drag on the text itself. Forward
padding presses to the editable via pointer capture: focus it, anchor a
caret at the pointer, and extend the selection as the pointer moves, so
the whole box up to the buttons is drag-selectable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 679cef00-4867-4bba-8efe-3daac6103863
Extract fireInputEvent() helper for the three identical programmatic 'input' event dispatches in contextMenu.ts, and remove the unused isCopy local in handleClipboardShortcut (it only fed the guard). No behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 679cef00-4867-4bba-8efe-3daac6103863
@GeorgeNgMsft
GeorgeNgMsft marked this pull request as ready for review July 21, 2026 19:50
@GeorgeNgMsft
GeorgeNgMsft enabled auto-merge July 21, 2026 20:06
@GeorgeNgMsft
GeorgeNgMsft added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit ba1f471 Jul 21, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants