Skip to content

Add Copy Button to Hover Content#271990

Merged
benvillalobos merged 18 commits intomicrosoft:mainfrom
benvillalobos:exp/copy-on-hover
Oct 29, 2025
Merged

Add Copy Button to Hover Content#271990
benvillalobos merged 18 commits intomicrosoft:mainfrom
benvillalobos:exp/copy-on-hover

Conversation

@benvillalobos
Copy link
Member

@benvillalobos benvillalobos commented Oct 17, 2025

Fixes #209415

Adds a copy button to all MarkerHovers. This includes Info, Hint, Warning, and Error hovers (anything with a code included in the message).

  • Copy button shows on hover or tab-selection
  • Enter or Space keypress supported
  • Visibility controlled entirely by CSS
  • Includes tests

Known Issues

  • getAccessibleContent (the method that extracts text out of hovers) does not include additionalInformation. See in the video how the second copy does not include the second line
copy.mp4

Remove fading animation, increase font size

Set pointer-events auto on .hover-copy-button

Set button opacity to 1 when showing
Nits

Test not showing on color picker

Revert "Test not showing on color picker"

This reverts commit 9637876.

Remove all uses of opacity

Nit: remove comment

Remove comment
…may want to plug into AI

Use dom.show and hide

Hover copy button: Apply css class instead of manually applying attributes

Nits: Remove hover css and remove empty line

Remove redundant codicon class assignment
Simplify tooltip

Remove one line fn

Remove z index

Use helper fn for keydown event

Use clickaction helper

Add jsdoc

The copy button should add the class to its container
Remove unnecessary css vars
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a copy button to marker hover parts so users can copy hover content via click or keyboard (Enter/Space). Key changes:

  • Introduces HoverCopyButton component and integrates it into marker hover rendering.
  • Adds CSS for conditional visibility and styling of the copy button.
  • Adds unit tests for presence and interaction (click and keyboard) of the copy button.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/vs/editor/contrib/hover/browser/hoverCopyButton.ts Implements the HoverCopyButton logic and accessibility attributes.
src/vs/editor/contrib/hover/browser/contentHoverWidgetWrapper.ts Wires clipboard service through to rendered hover parts.
src/vs/editor/contrib/hover/browser/contentHoverRendered.ts Integrates copy button into marker hover parts using accessible content source.
src/vs/editor/contrib/hover/browser/hover.css Adds layout and visibility rules for copy button.
src/vs/editor/contrib/hover/test/browser/hoverCopyButton.test.ts Adds tests for creation and interaction of the copy button.

@benvillalobos benvillalobos enabled auto-merge (squash) October 24, 2025 17:15
@benvillalobos benvillalobos merged commit 42dab51 into microsoft:main Oct 29, 2025
17 checks passed
dmitrivMS pushed a commit that referenced this pull request Oct 29, 2025
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add button to copy the hover content

2 participants