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

Test contributing actions to extension context menu #89361

Closed
2 tasks done
sandy081 opened this issue Jan 27, 2020 · 2 comments
Closed
2 tasks done

Test contributing actions to extension context menu #89361

sandy081 opened this issue Jan 27, 2020 · 2 comments

Comments

@sandy081
Copy link
Member

sandy081 commented Jan 27, 2020

Testing #87285

Complexity: 3


Testing

Extensions can now contribute actions to an extension's context menu in extension viewlet using the new menu location extension/context. You can use the when condition "when": "extensionStatus==installed" if you want to have the action only on installed extensions.

Develop an extension that can contribute an action to extension's context menu

  • Make sure the action is shown based on the context you defined.

  • Make sure your command is called with the extension id as argument

@sandy081 sandy081 added this to the January 2020 milestone Jan 27, 2020
@dbaeumer dbaeumer removed their assignment Jan 28, 2020
@miguelsolorio
Copy link
Contributor

miguelsolorio commented Jan 28, 2020

@sandy081 I can't get this to work, can you provide a sample extension that does this? Here's my basic extension:

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

	console.log('### activated');
	context.subscriptions.push(registerCommand());
}

function registerCommand() {
	return vscode.commands.registerCommand('extension.helloWorld', async extensionId => {
		console.log(extensionId);
		vscode.window.showInformationMessage('Hello World');
	});
}

and my package.json:

	"contributes": {
		"commands": [
			{
				"command": "extension.helloWorld",
				"title": "👋 Hello World"
			}
		]
	},
	"menus": {
		"extension/context": [
			{
				"command": "extension.helloWorld",
				"group": "2_configure"
			}
		]
	},

And I'm assuming "extension context menu" means the gear icon in the extension viewlet on the specific extension? Or is this a different context menu?

@miguelsolorio
Copy link
Contributor

Forgot that the menus needs to be part of contributes. It's working now:

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants