Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assistant2: Add "Copy code" button to code blocks #22866

Merged
merged 3 commits into from
Jan 9, 2025
Merged

Conversation

rtfeldman
Copy link
Contributor

@rtfeldman rtfeldman commented Jan 8, 2025

Here's what it looks like, including the "Copy" hover text in one case:

screenshot

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 8, 2025
@danilo-leal danilo-leal changed the title Add "Copy code" button to assistant2 markdown blocks assistant2: Add "Copy code" button to code blocks Jan 9, 2025
@rtfeldman rtfeldman added this pull request to the merge queue Jan 9, 2025
Merged via the queue into main with commit 7d905d0 Jan 9, 2025
14 checks passed
@rtfeldman rtfeldman deleted the copy-code-button branch January 9, 2025 14:50
github-merge-queue bot pushed a commit that referenced this pull request Jan 10, 2025
Follow-up of #22866

Added a config option to the markdown renderer to omit code copying
buttons, and used those for editor hover popovers.

Such popovers are quite frequent in language servers' hover responses,
e.g. rust-analyzer on `.clone()` hover may respond with
```
{"jsonrpc":"2.0","id":119,"result":{"contents":{"kind":"markdown","value":"\n```rust\nalloc::string::String\n```\n\n```rust\nfn clone(&self) -> Self\n```\n\n---\n\nReturns a copy of the value.\n\n# Examples\n\n```rust\nlet hello = \"Hello\"; // &str implements Clone\n\nassert_eq!(\"Hello\", hello.clone());\n```"},"range":{"start":{"line":518,"character":24},"end":{"line":518,"character":29}}}}
```

(note multiple code blocks sent)


![image](https://github.com/user-attachments/assets/4c40b15e-8f53-4b3d-a809-f1e4d35a00a7)


![image](https://github.com/user-attachments/assets/77b8e13b-b665-42d3-b633-5a0375998f06)

Sounds that editor has either to use a different way to copy popover's
data (so the entire text gets copied, not just its code blocks), or at
least better handle hover popover's hovering to show the button.


Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants