feat: add Copy Reference context menu for databases and collections [reviewed]#587
Merged
feat: add Copy Reference context menu for databases and collections [reviewed]#587
Conversation
Adds a "Copy Reference" right-click option to database and collection nodes in the sidebar. Database copies the db name, collection copies db.collection dot notation.
…iate titles Extracts shared logic into copyReferenceInternal helper. Renames command titles to "Copy Database Reference" and "Copy Collection Reference" to avoid duplicate labels in VS Code command/keybinding lists.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new “Copy Reference” actions to the extension’s tree view so users can quickly copy database/collection references from the sidebar.
Changes:
- Registered two new commands (
copyDatabaseReference,copyCollectionReference) in the extension command wiring. - Implemented clipboard-copy behavior for database name and
db.collectionreference formats. - Contributed the commands to VS Code menus (context menu) and added a localized confirmation message.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/documentdb/ClustersExtension.ts |
Registers the new tree-item commands so they can be invoked from the UI. |
src/commands/copyReference/copyReference.ts |
Implements the clipboard write + user confirmation message for database/collection references. |
package.json |
Declares the new commands and adds context-menu entries for database/collection nodes. |
l10n/bundle.l10n.json |
Adds localization entry for the “copied to clipboard” confirmation message. |
Collaborator
Author
sajeetharan
approved these changes
Apr 16, 2026
Merged
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.

Reviewing and merging: #545
Summary
Thanks to @bgaeddert for kicking this off and for the inspiration! 🎉
Starting from the original contribution that added "Copy Reference" for databases and collections, we've expanded and refined the feature:
What changed
copyReferencecommand handles all node types, detecting the node viainstanceofat runtime. No more separate commands per node type.use dbName), Qualified Name (host/dbName)db.coll), Shell Reference (db.coll), Shell Command (db.getCollection("coll")){ field: 1 }), Shell Command (db.coll.getIndexes().find(...))db.getCollection("...")form. Dot-notation options are hidden when they would produce broken syntax.context.ui.showQuickPickwithsuppressPersistence: truefor stable ordering — follows the same pattern as other wizard-style commands in the codebase.Feedback requested
@bgaeddert — the main change from your original PR is the addition of a QuickPick step to choose the format. We'd love your feedback on whether that extra step is acceptable to you. If you'd prefer a zero-click experience, we could follow up with a PR that adds a user setting to define a preferred default format — when set, it would copy directly without showing the picker.